You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"SELECT * FROM agent_agenda WHERE status = 'active' ORDER BY CASE priority WHEN 'high' THEN 0 WHEN 'medium' THEN 1 ELSE 2 END, created_at ASC"
53
-
).all();
53
+
exportasyncfunctiongetActiveAgendaItems(
54
+
db: D1Database,
55
+
businessUnit?: string,
56
+
): Promise<AgendaItem[]>{
57
+
constsql=businessUnit
58
+
? "SELECT * FROM agent_agenda WHERE status = 'active' AND business_unit = ? ORDER BY CASE priority WHEN 'high' THEN 0 WHEN 'medium' THEN 1 ELSE 2 END, created_at ASC"
59
+
: "SELECT * FROM agent_agenda WHERE status = 'active' ORDER BY CASE priority WHEN 'high' THEN 0 WHEN 'medium' THEN 1 ELSE 2 END, created_at ASC";
60
+
conststmt=businessUnit
61
+
? db.prepare(sql).bind(businessUnit)
62
+
: db.prepare(sql);
63
+
constresult=awaitstmt.all();
54
64
returnresult.resultsasunknownasAgendaItem[];
55
65
}
56
66
@@ -70,16 +80,19 @@ export async function addAgendaItem(
70
80
item: string,
71
81
context: string|undefined,
72
82
priority: AgendaPriority,
83
+
businessUnit: string=DEFAULT_BUSINESS_UNIT,
73
84
): Promise<number>{
74
85
// Dedup: check for existing active OR recently resolved items with similar text (#72)
75
86
// Include items resolved within 7 days to prevent zombie re-creation loops
76
87
// where a compliance item is re-flagged before the upstream source is updated.
// Dedup scoped to the same business_unit — different BUs can have
92
+
// legitimately overlapping item text without being duplicates.
80
93
constcandidates=awaitdb.prepare(
81
-
"SELECT id, item, priority, status FROM agent_agenda WHERE status = 'active' OR (status IN ('done', 'dismissed') AND resolved_at >= datetime('now', '-7 days'))"
"SELECT id, item, priority, status FROM agent_agenda WHERE business_unit = ? AND (status = 'active' OR (status IN ('done', 'dismissed') AND resolved_at >= datetime('now', '-7 days')))"
0 commit comments