From 7d53e2e458cba7153dea27c625ca1bb534952ddf Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Sun, 8 Feb 2026 01:40:24 +0000 Subject: fix: lower the priority of recrawling --- packages/shared-server/src/queues.ts | 5 +++++ packages/trpc/routers/admin.ts | 17 +++++++++-------- packages/trpc/routers/bookmarks.ts | 7 ++++++- 3 files changed, 20 insertions(+), 9 deletions(-) (limited to 'packages') diff --git a/packages/shared-server/src/queues.ts b/packages/shared-server/src/queues.ts index 38c7bfe1..fd9dac83 100644 --- a/packages/shared-server/src/queues.ts +++ b/packages/shared-server/src/queues.ts @@ -11,6 +11,11 @@ import { zRuleEngineEventSchema } from "@karakeep/shared/types/rules"; import { loadAllPlugins } from "."; +export enum QueuePriority { + Low = 50, + Default = 0, +} + // Lazy client initialization - plugins are loaded on first access // We cache the promise to ensure only one initialization happens even with concurrent calls let clientPromise: Promise | null = null; diff --git a/packages/trpc/routers/admin.ts b/packages/trpc/routers/admin.ts index 48d09ad2..909e84d1 100644 --- a/packages/trpc/routers/admin.ts +++ b/packages/trpc/routers/admin.ts @@ -10,6 +10,7 @@ import { FeedQueue, LinkCrawlerQueue, OpenAIQueue, + QueuePriority, SearchIndexingQueue, triggerSearchReindex, VideoWorkerQueue, @@ -226,7 +227,7 @@ export const adminAppRouter = router({ runInference: input.runInference, }, { - priority: 50, + priority: QueuePriority.Low, }, ), ), @@ -244,7 +245,7 @@ export const adminAppRouter = router({ await Promise.all( bookmarkIds.map((b) => triggerSearchReindex(b.id, { - priority: 50, + priority: QueuePriority.Low, }), ), ); @@ -264,7 +265,7 @@ export const adminAppRouter = router({ fixMode: true, }, { - priority: 50, + priority: QueuePriority.Low, }, ), ), @@ -299,7 +300,7 @@ export const adminAppRouter = router({ OpenAIQueue.enqueue( { bookmarkId: b.id, type: input.type }, { - priority: 50, + priority: QueuePriority.Low, }, ), ), @@ -667,7 +668,7 @@ export const adminAppRouter = router({ bookmarkId: input.bookmarkId, }, { - priority: 50, + priority: QueuePriority.Low, groupId: "admin", }, ); @@ -688,7 +689,7 @@ export const adminAppRouter = router({ } await triggerSearchReindex(input.bookmarkId, { - priority: 50, + priority: QueuePriority.Low, groupId: "admin", }); }), @@ -713,7 +714,7 @@ export const adminAppRouter = router({ type: "tag", }, { - priority: 50, + priority: QueuePriority.Low, groupId: "admin", }, ); @@ -746,7 +747,7 @@ export const adminAppRouter = router({ type: "summarize", }, { - priority: 50, + priority: QueuePriority.Low, groupId: "admin", }, ); diff --git a/packages/trpc/routers/bookmarks.ts b/packages/trpc/routers/bookmarks.ts index 59c93581..0bbf4fb7 100644 --- a/packages/trpc/routers/bookmarks.ts +++ b/packages/trpc/routers/bookmarks.ts @@ -20,6 +20,7 @@ import { AssetPreprocessingQueue, LinkCrawlerQueue, OpenAIQueue, + QueuePriority, QuotaService, triggerRuleEngineOnEvent, triggerSearchReindex, @@ -271,7 +272,10 @@ export const bookmarksAppRouter = router({ const enqueueOpts: EnqueueOptions = { // The lower the priority number, the sooner the job will be processed - priority: input.crawlPriority === "low" ? 50 : 0, + priority: + input.crawlPriority === "low" + ? QueuePriority.Low + : QueuePriority.Default, groupId: ctx.user.id, }; @@ -568,6 +572,7 @@ export const bookmarksAppRouter = router({ }, { groupId: ctx.user.id, + priority: QueuePriority.Low, }, ); }), -- cgit v1.2.3-70-g09d2