mirror of
https://github.com/coder/coder.git
synced 2026-06-03 04:58:23 +00:00
a876287d36
Adds a background job in `dbpurge` that periodically archives chats inactive beyond a configurable threshold. Each archived root chat gets a background audit entry tagged `chat_auto_archive`. Disabled by default. * New `AutoArchiveInactiveChats` SQL query with LATERAL last-activity subquery and partial index on archive candidates * `site_configs`-backed `auto_archive_days` setting with admin-only PUT, any-authenticated-user GET * Cascade archive via `root_chat_id`; pinned chats and active threads exempt * Root-only audit dispatch on detached context, matching manual archive (`patchChat`) behavior * 11 subtests covering disabled no-op, boundary, deleted messages, child activity, pinned exemption, multi-owner, idempotency, and batch pagination PR #24643 adds per-owner digest notifications. PR #24704 adds the requisite UI controls. > 🤖
11 lines
497 B
SQL
11 lines
497 B
SQL
-- Partial index matching the AutoArchiveInactiveChats WHERE clause so
|
|
-- dbpurge can skip the bulk of archived / pinned / child chats.
|
|
-- The status predicate lives in the query, not the index, because
|
|
-- enum values added by earlier migrations cannot be referenced in
|
|
-- index predicates within the same transaction batch.
|
|
CREATE INDEX IF NOT EXISTS idx_chats_auto_archive_candidates
|
|
ON chats (created_at)
|
|
WHERE archived = false
|
|
AND pin_order = 0
|
|
AND parent_chat_id IS NULL;
|