Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

fix: remove unnecessary cleanupOrphanedUnread from inbox queries

Gus2e29e6fe4c2e
diff --git a/src/shared/src/db/queries/inbox.ts b/src/shared/src/db/queries/inbox.ts
index dc233cfbe..702978d9f 100644
--- a/src/shared/src/db/queries/inbox.ts
+++ b/src/shared/src/db/queries/inbox.ts
@@ -119,22 +119,12 @@ export async function findLatestAssistantMessageId(
return rows[0]?.id ?? null;
}
-export async function cleanupOrphanedUnread(db: Database, userId: string, workspaceId: string) {
- await db.run(sql`
- DELETE FROM inbox_unread
- WHERE user_id = ${userId}
- AND workspace_id = ${workspaceId}
- AND conversation_id NOT IN (SELECT id FROM conversation)
- `);
-}
-
export async function listUnreadConversations(
db: Database,
userId: string,
workspaceId: string,
opts?: { limit?: number; before?: string; types?: string[] }
) {
- await cleanupOrphanedUnread(db, userId, workspaceId);
const limit = opts?.limit ?? 30;
const beforeClause = opts?.before
? sql`AND u.completed_at < ${opts.before}`
diff --git a/src/shared/test/queries/inbox.test.ts b/src/shared/test/queries/inbox.test.ts
index d0a0e68ac..fb0fa0138 100644
--- a/src/shared/test/queries/inbox.test.ts
+++ b/src/shared/test/queries/inbox.test.ts
@@ -23,7 +23,6 @@ describe("inbox exports", () => {
it("exports deleteAllUnreadEntries", () => { expect(typeof inboxQueries.deleteAllUnreadEntries).toBe("function"); });
it("exports findLatestAssistantMessageId", () => { expect(typeof inboxQueries.findLatestAssistantMessageId).toBe("function"); });
it("exports isUnreadEligible", () => { expect(typeof inboxQueries.isUnreadEligible).toBe("function"); });
- it("exports cleanupOrphanedUnread", () => { expect(typeof inboxQueries.cleanupOrphanedUnread).toBe("function"); });
});
// ---------------------------------------------------------------------------
@@ -161,18 +160,6 @@ describe("deleteAllUnreadEntries", () => {
});
});
-// ---------------------------------------------------------------------------
-// cleanupOrphanedUnread
-// ---------------------------------------------------------------------------
-
-describe("cleanupOrphanedUnread", () => {
- it("calls db.run for DELETE", async () => {
- const mockDb = createMockDb([]);
- await inboxQueries.cleanupOrphanedUnread(mockDb, "u1", "w1");
- expect(mockDb.run).toHaveBeenCalled();
- });
-});
-
// ---------------------------------------------------------------------------
// TC9 / TC11: listUnreadConversations (rewritten query)
// ---------------------------------------------------------------------------