Skip to content

Commit

Permalink
Fix breaking searchIndex bug (#594)
Browse files Browse the repository at this point in the history
* Remove newParams logic

* Update config.ts

* Update config.ts
  • Loading branch information
jeffdaley authored Feb 13, 2024
1 parent eb1a127 commit aae0c96
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
9 changes: 1 addition & 8 deletions web/app/services/algolia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,7 @@ export default class AlgoliaService extends Service {
params: AlgoliaSearchParams,
): Promise<SearchResponse<unknown>> => {
let index: SearchIndex = this.client.initIndex(indexName);

let newParams = { ...params };

newParams.data = {
indexName,
};

return await index.search(query, newParams);
return await index.search(query, params);
},
);

Expand Down
7 changes: 2 additions & 5 deletions web/mirage/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ export default function (mirageConfig) {
* Reviews the request and determines how to respond.
*/
const handleAlgoliaRequest = (schema, request) => {
const indexName = request.url.split("indexes/")[1].split("/")[0];
const requestBody = JSON.parse(request.requestBody);

if (requestBody) {
console.log("requestBody", requestBody);
const { facetQuery, query } = requestBody;
Expand Down Expand Up @@ -90,15 +92,10 @@ export default function (mirageConfig) {
* Typically, this is a query for a document, project or product,
* but sometimes it's a query by some optionalFilters.
*/

// The algolia `searchIndex` method includes an indexName.
const { indexName } = requestBody;

if (indexName?.includes("projects")) {
const projects = schema.projects
.all()
.models.filter((project) => {
console.log("project", project);
return (
project.attrs.title
.toLowerCase()
Expand Down

0 comments on commit aae0c96

Please sign in to comment.