diff options
| author | MohamedBassem <me@mbassem.com> | 2024-03-30 16:26:16 +0000 |
|---|---|---|
| committer | MohamedBassem <me@mbassem.com> | 2024-03-30 16:26:16 +0000 |
| commit | 46b78eaac30be26fe40520e97786563344af8403 (patch) | |
| tree | c4c0e1ae1d3d21a6f1fbf5f44f68e99243bbb5d3 /packages/shared/search.ts | |
| parent | 853ed13450b3a0d92cba144cc0dfd0696e7c810c (diff) | |
| download | karakeep-46b78eaac30be26fe40520e97786563344af8403.tar.zst | |
format: Add missing lint and format, and format the entire repo
Diffstat (limited to 'packages/shared/search.ts')
| -rw-r--r-- | packages/shared/search.ts | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/packages/shared/search.ts b/packages/shared/search.ts index 8422d79e..7cd81061 100644 --- a/packages/shared/search.ts +++ b/packages/shared/search.ts @@ -1,7 +1,9 @@ -import { MeiliSearch, Index } from "meilisearch"; -import serverConfig from "./config"; +import type { Index } from "meilisearch"; +import { MeiliSearch } from "meilisearch"; import { z } from "zod"; +import serverConfig from "./config"; + export const zBookmarkIdxSchema = z.object({ id: z.string(), userId: z.string(), @@ -51,15 +53,29 @@ export async function getSearchIdxClient(): Promise<Index<ZBookmarkIdx> | null> const desiredSortableAttributes = ["createdAt"].sort(); const settings = await idxFound.getSettings(); - if (JSON.stringify(settings.filterableAttributes?.sort()) != JSON.stringify(desiredFilterableAttributes)) { - console.log(`[meilisearch] Updating desired filterable attributes to ${desiredFilterableAttributes} from ${settings.filterableAttributes}`); - const taskId = await idxFound.updateFilterableAttributes(desiredFilterableAttributes); + if ( + JSON.stringify(settings.filterableAttributes?.sort()) != + JSON.stringify(desiredFilterableAttributes) + ) { + console.log( + `[meilisearch] Updating desired filterable attributes to ${desiredFilterableAttributes} from ${settings.filterableAttributes}`, + ); + const taskId = await idxFound.updateFilterableAttributes( + desiredFilterableAttributes, + ); await searchClient.waitForTask(taskId.taskUid); } - if (JSON.stringify(settings.sortableAttributes?.sort()) != JSON.stringify(desiredSortableAttributes)) { - console.log(`[meilisearch] Updating desired sortable attributes to ${desiredSortableAttributes} from ${settings.sortableAttributes}`); - const taskId = await idxFound.updateSortableAttributes(desiredSortableAttributes); + if ( + JSON.stringify(settings.sortableAttributes?.sort()) != + JSON.stringify(desiredSortableAttributes) + ) { + console.log( + `[meilisearch] Updating desired sortable attributes to ${desiredSortableAttributes} from ${settings.sortableAttributes}`, + ); + const taskId = await idxFound.updateSortableAttributes( + desiredSortableAttributes, + ); await searchClient.waitForTask(taskId.taskUid); } idxClient = idxFound; |
