diff options
| author | kamtschatka <sschatka@gmail.com> | 2024-06-09 20:11:23 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-09 19:11:23 +0100 |
| commit | 546139e82f151b35d6492b7cbf2ac89dbfd5d0b5 (patch) | |
| tree | aa966a810f68ec79afbb4fd606adaa6bd49538e3 /packages/trpc/routers/bookmarks.ts | |
| parent | be1bb388924f4422058099dcb0debdd1c857d36a (diff) | |
| download | karakeep-546139e82f151b35d6492b7cbf2ac89dbfd5d0b5.tar.zst | |
fix: Trigger search re-index on bookmark tag manual updates. Fixes #208 (#210)
* re-index of database is not scanning all places when bookmark tags are changed. Manual indexing is working as workaround #208
introduced a new function to trigger a reindex to reduce copy/paste
added missing reindexes when tags are deleted/bookmarks are updated
* give functions a bit more descriptive name
---------
Co-authored-by: kamtschatka <simon.schatka@gmx.at>
Co-authored-by: MohamedBassem <me@mbassem.com>
Diffstat (limited to 'packages/trpc/routers/bookmarks.ts')
| -rw-r--r-- | packages/trpc/routers/bookmarks.ts | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/packages/trpc/routers/bookmarks.ts b/packages/trpc/routers/bookmarks.ts index 5f53dd16..15a8c7c0 100644 --- a/packages/trpc/routers/bookmarks.ts +++ b/packages/trpc/routers/bookmarks.ts @@ -22,7 +22,8 @@ import { deleteAsset } from "@hoarder/shared/assetdb"; import { LinkCrawlerQueue, OpenAIQueue, - SearchIndexingQueue, + triggerSearchDeletion, + triggerSearchReindex, } from "@hoarder/shared/queues"; import { getSearchIdxClient } from "@hoarder/shared/search"; import { @@ -295,10 +296,7 @@ export const bookmarksAppRouter = router({ break; } } - SearchIndexingQueue.add("search_indexing", { - bookmarkId: bookmark.id, - type: "index", - }); + triggerSearchReindex(bookmark.id); return bookmark; }), @@ -328,10 +326,7 @@ export const bookmarksAppRouter = router({ message: "Bookmark not found", }); } - SearchIndexingQueue.add("search_indexing", { - bookmarkId: input.bookmarkId, - type: "index", - }); + triggerSearchReindex(input.bookmarkId); return res[0]; }), @@ -357,10 +352,7 @@ export const bookmarksAppRouter = router({ message: "Bookmark not found", }); } - SearchIndexingQueue.add("search_indexing", { - bookmarkId: input.bookmarkId, - type: "index", - }); + triggerSearchReindex(input.bookmarkId); }), deleteBookmark: authedProcedure @@ -385,10 +377,7 @@ export const bookmarksAppRouter = router({ eq(bookmarks.id, input.bookmarkId), ), ); - SearchIndexingQueue.add("search_indexing", { - bookmarkId: input.bookmarkId, - type: "delete", - }); + triggerSearchDeletion(input.bookmarkId); if (deleted.changes > 0 && bookmark) { await cleanupAssetForBookmark({ asset: bookmark.asset, @@ -708,6 +697,7 @@ export const bookmarksAppRouter = router({ })), ) .onConflictDoNothing(); + triggerSearchReindex(input.bookmarkId); return { bookmarkId: input.bookmarkId, attached: allIds, |
