Initial import of LWLT AIBOT platform

This commit is contained in:
inman
2026-08-25 10:33:29 +08:00
commit 208c434b31
2178 changed files with 382042 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
-- Keep the operator list and active-task scans bounded by organization and
-- lifecycle status. The list API still applies LIMIT/OFFSET, while these
-- indexes avoid sorting/reading large unrelated task sets as data grows.
CREATE INDEX IF NOT EXISTS tasks_visible_created_idx
ON tasks (organization_id, created_at DESC, id DESC)
WHERE status <> 'cancelled';
CREATE INDEX IF NOT EXISTS tasks_active_status_created_idx
ON tasks (organization_id, status, created_at DESC, id DESC)
WHERE status IN ('queued', 'accepted', 'running', 'reconciliation_pending');
CREATE INDEX IF NOT EXISTS tasks_active_handoff_created_idx
ON tasks (organization_id, handoff_status, created_at DESC, id DESC)
WHERE handoff_status IN ('accepted', 'running', 'reconciliation_pending');
CREATE INDEX IF NOT EXISTS task_events_org_task_idx
ON task_events (organization_id, task_id, id);