Align registration status and crisp slice masks

This commit is contained in:
Codex
2026-05-30 15:40:51 +08:00
parent 30f73937aa
commit cad4257a4b
4 changed files with 33 additions and 42 deletions

View File

@@ -529,10 +529,16 @@ def relation_cte() -> str:
r AS (
SELECT
upper(ct_number) AS ct_key,
count(*)::int AS registration_count,
count(DISTINCT series_instance_uid) FILTER (WHERE series_instance_uid <> '')::int AS registered_series,
count(*) FILTER (WHERE locked)::int AS locked_count,
max(updated_at) AS registration_updated_at
count(*) FILTER (WHERE COALESCE(registration_status, 'unregistered') = 'registered')::int AS registration_count,
count(DISTINCT series_instance_uid) FILTER (
WHERE COALESCE(registration_status, 'unregistered') = 'registered'
AND series_instance_uid <> ''
)::int AS registered_series,
count(*) FILTER (
WHERE COALESCE(registration_status, 'unregistered') = 'registered'
AND COALESCE(locked, false)
)::int AS locked_count,
max(updated_at) FILTER (WHERE COALESCE(registration_status, 'unregistered') = 'registered') AS registration_updated_at
FROM public.{REGISTRATION_TABLE_SQL}
GROUP BY upper(ct_number)
),