feat: add feedback resolver

This commit is contained in:
Krispire Admin
2026-06-03 23:43:17 +05:30
parent 61b91c473b
commit e9a96f1ff9
7 changed files with 211 additions and 16 deletions
@@ -0,0 +1,2 @@
DROP INDEX IF EXISTS idx_feedback_unresolved;
ALTER TABLE feedback DROP COLUMN IF EXISTS resolved_at;
@@ -0,0 +1,19 @@
-- Track when a feedback row was resolved.
--
-- NULL = still open. Non-NULL = closed at that moment. The action is
-- one-way: the resolve endpoint enforces `WHERE resolved_at IS NULL` so
-- a row already marked stays marked, and a subsequent re-resolve is a
-- no-op (no new email goes out).
--
-- We don't store "who" resolved it because the /stats page surfaces
-- this to the team and any audit-quality "who closed what" trail would
-- want its own table — out of scope for now.
ALTER TABLE feedback
ADD COLUMN IF NOT EXISTS resolved_at TIMESTAMPTZ;
-- Partial index makes "give me the still-open feedback" cheap as the
-- table grows. The /stats page lists newest-first regardless of state,
-- so the existing created_at index still serves its read path.
CREATE INDEX IF NOT EXISTS idx_feedback_unresolved
ON feedback (created_at DESC)
WHERE resolved_at IS NULL;