A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search
fix(workers): avoid doing empty insertions in the tagging worker
Mohamed Bassem186b76eb0ab1
diff --git a/apps/workers/workers/inference/tagging.ts b/apps/workers/workers/inference/tagging.tsindex 668c1d5e..3750b474 100644--- a/apps/workers/workers/inference/tagging.ts+++ b/apps/workers/workers/inference/tagging.ts@@ -461,17 +461,20 @@ async function connectTags(const allTagIds = new Set([...matchedTagIds, ...newTagIds]);// Attach new ones- const attachedTags = await tx- .insert(tagsOnBookmarks)- .values(- [...allTagIds].map((tagId) => ({- tagId,- bookmarkId,- attachedBy: "ai" as const,- })),- )- .onConflictDoNothing()- .returning();+ let attachedTags: { tagId: string; bookmarkId: string }[] = [];+ if (allTagIds.size > 0) {+ attachedTags = await tx+ .insert(tagsOnBookmarks)+ .values(+ [...allTagIds].map((tagId) => ({+ tagId,+ bookmarkId,+ attachedBy: "ai" as const,+ })),+ )+ .onConflictDoNothing()+ .returning();+ }return { detachedTags, attachedTags };});