diff --git a/apps/web/components/dashboard/admin/AdminActions.tsx b/apps/web/components/dashboard/admin/AdminActions.tsx index e5d6ed69..a97552f8 100644 --- a/apps/web/components/dashboard/admin/AdminActions.tsx +++ b/apps/web/components/dashboard/admin/AdminActions.tsx @@ -101,7 +101,16 @@ export default function AdminActions() { reRunInferenceOnAllBookmarks()} + onClick={() => + reRunInferenceOnAllBookmarks({ taggingStatus: "failure" }) + } + > + Regenerate AI Tags for Failed Bookmarks Only + + reRunInferenceOnAllBookmarks({ taggingStatus: "all" })} > Regenerate AI Tags for All Bookmarks diff --git a/packages/trpc/routers/admin.ts b/packages/trpc/routers/admin.ts index ff1249d0..d8ffe9d3 100644 --- a/packages/trpc/routers/admin.ts +++ b/packages/trpc/routers/admin.ts @@ -145,17 +145,26 @@ export const adminAppRouter = router({ await Promise.all(bookmarkIds.map((b) => triggerSearchReindex(b.id))); }), - reRunInferenceOnAllBookmarks: adminProcedure.mutation(async ({ ctx }) => { - const bookmarkIds = await ctx.db.query.bookmarks.findMany({ - columns: { - id: true, - }, - }); + reRunInferenceOnAllBookmarks: adminProcedure + .input( + z.object({ + taggingStatus: z.enum(["success", "failure", "all"]), + }), + ) + .mutation(async ({ input, ctx }) => { + const bookmarkIds = await ctx.db.query.bookmarks.findMany({ + columns: { + id: true, + }, + ...(input.taggingStatus === "all" + ? {} + : { where: eq(bookmarks.taggingStatus, input.taggingStatus) }), + }); - await Promise.all( - bookmarkIds.map((b) => OpenAIQueue.enqueue({ bookmarkId: b.id })), - ); - }), + await Promise.all( + bookmarkIds.map((b) => OpenAIQueue.enqueue({ bookmarkId: b.id })), + ); + }), tidyAssets: adminProcedure.mutation(async () => { await TidyAssetsQueue.enqueue({ cleanDanglingAssets: true,