Show annotated and unannotated series counts

This commit is contained in:
Codex
2026-05-27 10:40:49 +08:00
parent bbf8466d56
commit 0f06b04bf7
2 changed files with 33 additions and 4 deletions

View File

@@ -350,7 +350,7 @@ def studies(_: str = Depends(require_auth), q: str = "", limit: int = 200) -> li
SELECT
ct_number, batch_name, target_folder_name, source_patient_name, patient_name_dicom,
patient_id, study_date, study_time, modality, dicom_file_count,
processed_path, needs_ct_number_fix, status
series_count, processed_path, needs_ct_number_fix, status
FROM public.{PGTABLE}
{where}
ORDER BY study_date DESC NULLS LAST, study_time DESC NULLS LAST, ct_number
@@ -361,14 +361,20 @@ def studies(_: str = Depends(require_auth), q: str = "", limit: int = 200) -> li
"""
SELECT ct_number, count(*)::int AS annotated_series
FROM public.pacs_dicom_series_annotations
WHERE skipped IS NOT TRUE AND jsonb_array_length(body_parts) > 0
WHERE skipped IS TRUE
OR jsonb_array_length(body_parts) > 0
OR plain_ct IS TRUE
OR NULLIF(notes, '') IS NOT NULL
OR ai_result IS NOT NULL
GROUP BY ct_number
""",
timeout=8,
)
annotation_map = {row["ct_number"]: row["annotated_series"] for row in annotations}
for row in rows:
row["annotated_series"] = annotation_map.get(row["ct_number"], 0)
total_series = int(row.get("series_count") or 0)
row["annotated_series"] = min(total_series, int(annotation_map.get(row["ct_number"], 0)))
row["unannotated_series"] = max(0, total_series - int(row["annotated_series"]))
return rows