feat: route ecc2 by handoff backlog

This commit is contained in:
Affaan Mustafa
2026-04-08 03:47:11 -07:00
parent 478466168a
commit 3199120abe
3 changed files with 170 additions and 6 deletions

View File

@@ -555,6 +555,19 @@ impl StateStore {
.map_err(Into::into)
}
pub fn unread_task_handoff_count(&self, session_id: &str) -> Result<usize> {
self.conn
.query_row(
"SELECT COUNT(*)
FROM messages
WHERE to_session = ?1 AND msg_type = 'task_handoff' AND read = 0",
rusqlite::params![session_id],
|row| row.get::<_, i64>(0),
)
.map(|count| count as usize)
.map_err(Into::into)
}
pub fn unread_task_handoff_targets(&self, limit: usize) -> Result<Vec<(String, usize)>> {
let mut stmt = self.conn.prepare(
"SELECT to_session, COUNT(*) as unread_count