feat(iit): harden QC pipeline consistency and release artifacts
Implement IIT quality workflow hardening across eQuery deduplication, guard metadata validation, timeline/readability improvements, and chat evidence fallbacks, then synchronize release and development documentation for deployment handoff. Includes migration/scripts for open eQuery dedupe guards, orchestration/status semantics, report/tool readability fixes, and updated module status plus deployment checklist. Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
-- 1) 先收敛历史 open 重复,避免唯一索引创建失败
|
||||
WITH ranked AS (
|
||||
SELECT
|
||||
id,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY
|
||||
project_id,
|
||||
record_id,
|
||||
COALESCE(event_id, ''),
|
||||
COALESCE(category, '')
|
||||
ORDER BY
|
||||
CASE status
|
||||
WHEN 'reviewing' THEN 4
|
||||
WHEN 'responded' THEN 3
|
||||
WHEN 'reopened' THEN 2
|
||||
WHEN 'pending' THEN 1
|
||||
ELSE 0
|
||||
END DESC,
|
||||
updated_at DESC NULLS LAST,
|
||||
created_at DESC NULLS LAST,
|
||||
id DESC
|
||||
) AS rn
|
||||
FROM iit_schema.equery
|
||||
WHERE status IN ('pending', 'responded', 'reviewing', 'reopened')
|
||||
)
|
||||
UPDATE iit_schema.equery e
|
||||
SET
|
||||
status = 'auto_closed',
|
||||
closed_at = COALESCE(e.closed_at, NOW()),
|
||||
closed_by = COALESCE(e.closed_by, 'system_dedupe_migration'),
|
||||
resolution = COALESCE(
|
||||
NULLIF(e.resolution, ''),
|
||||
'自动去重收敛:同一受试者/事件/规则已存在未关闭 eQuery'
|
||||
),
|
||||
updated_at = NOW()
|
||||
FROM ranked r
|
||||
WHERE e.id = r.id
|
||||
AND r.rn > 1;
|
||||
|
||||
-- 2) 为 open 集合建立唯一去重键,防止未来重复写入
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS uq_iit_equery_open_dedupe_key
|
||||
ON iit_schema.equery (
|
||||
project_id,
|
||||
record_id,
|
||||
(COALESCE(event_id, '')),
|
||||
(COALESCE(category, ''))
|
||||
)
|
||||
WHERE status IN ('pending', 'responded', 'reviewing', 'reopened');
|
||||
Reference in New Issue
Block a user