Adds per-message AI moderation analysis time (ai_analysis_duration_ms) so operators can see how long the LLM took to moderate each message. Gateway: - messagesTable: new ai_analysis_duration_ms (bigint) column. - AIAnalysisUpdate + buildAIAnalysisSet: carry analysisDurationMs through both single and bulk update paths. - ai-analysis-worker: measure wall-clock time around runModerationAnalysis and attach it to every result in the batch. Backend: - Mirror schema column; messageMapper maps ai_analysis_duration_ms; moderation-types + MappedMessage expose it. Frontend: - message.ts type gains ai_analysis_duration_ms. - AiBadge (messages view) shows 'status · 1.2s' when duration is present; analysis view badge mirrors the same formatting. DB: - scripts/add-ai-analysis-duration.sql (idempotent ADD COLUMN IF NOT EXISTS). No behavior change for moderation logic; null until new gateway build records values.
11 lines
412 B
SQL
11 lines
412 B
SQL
-- Migration: add ai_analysis_duration_ms to messages
|
|
-- Tracks how long the AI moderation LLM call took, per message (ms).
|
|
-- Idempotent: safe to re-run.
|
|
--
|
|
-- Run against the production GMW database, e.g.:
|
|
-- PGPASSWORD=*** psql -h 100.121.180.82 -p 6432 -U asephs -d dcbot \
|
|
-- -f scripts/add-ai-analysis-duration.sql
|
|
|
|
ALTER TABLE "messages"
|
|
ADD COLUMN IF NOT EXISTS "ai_analysis_duration_ms" BIGINT;
|