fix: activity.ts pg_notify syntax and graph-service.ts sections empty inArray

This commit is contained in:
2026-07-29 13:03:55 +00:00
parent 4089d7464c
commit 83befd6a84
2 changed files with 6 additions and 11 deletions
+2 -10
View File
@@ -26,14 +26,6 @@ export async function recordActivity(params: RecordActivityParams): Promise<void
});
// Notify SSE subscribers
await sql.unsafe(
`SELECT pg_notify('project_e_events', ${JSON.stringify(
JSON.stringify({
type: entityType,
action,
id: entityId,
workspace_id: workspaceId,
})
)})`
);
const payload = JSON.stringify({ type: entityType, action, id: entityId, workspace_id: workspaceId });
await db.execute(sql.unsafe(`SELECT pg_notify('project_e_events', '${payload}')`));
}
+4 -1
View File
@@ -60,12 +60,15 @@ export async function getGraphData(domainId: string): Promise<GraphData> {
}
// Fetch all entities in this domain
const projectIds = (await db.select({ id: projects.id }).from(projects).where(eq(projects.domainId, domainId))).map(p => p.id);
const [noteRows, taskRows, habitRows, projectRows, sectionRows, tagRows, domainRows] = await Promise.all([
db.select({ id: notes.id, title: notes.title }).from(notes).where(and(eq(notes.domainId, domainId), isNull(notes.deletedAt))),
db.select({ id: tasks.id, title: tasks.title, projectId: tasks.projectId }).from(tasks).where(and(eq(tasks.domainId, domainId), isNull(tasks.deletedAt))),
db.select({ id: habits.id, name: habits.name }).from(habits).where(and(eq(habits.domainId, domainId), isNull(habits.deletedAt))),
db.select({ id: projects.id, name: projects.name }).from(projects).where(and(eq(projects.domainId, domainId), isNull(projects.deletedAt))),
db.select({ id: sections.id, name: sections.name, projectId: sections.projectId }).from(sections).where(eq(sections.projectId, inArray(sections.projectId, (await db.select({ id: projects.id }).from(projects).where(eq(projects.domainId, domainId))).map(p => p.id)))),
projectIds.length > 0
? db.select({ id: sections.id, name: sections.name, projectId: sections.projectId }).from(sections).where(inArray(sections.projectId, projectIds))
: Promise.resolve([]),
db.select({ id: tagsTable.id, name: tagsTable.name }).from(tagsTable),
db.select({ id: domains.id, name: domains.name }).from(domains).where(eq(domains.id, domainId)),
]);