From 8980d810d48ea70a50d3583d769a313120c99140 Mon Sep 17 00:00:00 2001 From: Marcel Date: Thu, 16 Apr 2026 11:00:18 +0200 Subject: [PATCH] fix(#240): use annotationCount as denominator in queue thresholds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ready-to-read and transcription queue queries were dividing reviewed blocks by textedBlockCount instead of annotationCount. A document with 4/15 annotations typed — all 4 reviewed — scored 4/4 = 100 % and incorrectly appeared in the Lesefertig column. Both queries now compute the ratio as: reviewed / annotationCount so a document must have ≥ 90 % of all its drawn regions reviewed before it graduates to Lesefertig. Co-Authored-By: Claude Sonnet 4.6 --- .../repository/DocumentRepository.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/backend/src/main/java/org/raddatz/familienarchiv/repository/DocumentRepository.java b/backend/src/main/java/org/raddatz/familienarchiv/repository/DocumentRepository.java index 499b486b..8b56a3f8 100644 --- a/backend/src/main/java/org/raddatz/familienarchiv/repository/DocumentRepository.java +++ b/backend/src/main/java/org/raddatz/familienarchiv/repository/DocumentRepository.java @@ -193,12 +193,9 @@ public interface DocumentRepository extends JpaRepository, JpaSp GROUP BY d.id, d.title, d.meta_date HAVING COUNT(DISTINCT da.id) > 0 AND ( - COUNT(DISTINCT CASE WHEN tb.text IS NOT NULL AND tb.text <> '' THEN tb.id END) = 0 - OR ( - COUNT(DISTINCT CASE WHEN tb.reviewed = true THEN tb.id END)::float / - NULLIF(COUNT(DISTINCT CASE WHEN tb.text IS NOT NULL AND tb.text <> '' THEN tb.id END), 0) - ) < 0.90 - ) + COUNT(DISTINCT CASE WHEN tb.reviewed = true THEN tb.id END)::float / + COUNT(DISTINCT da.id) + ) < 0.90 ORDER BY COUNT(DISTINCT CASE WHEN tb.text IS NOT NULL AND tb.text <> '' THEN tb.id END) DESC, HASHTEXT(d.id::text || EXTRACT(WEEK FROM NOW())::int::text) LIMIT :limit @@ -216,14 +213,13 @@ public interface DocumentRepository extends JpaRepository, JpaSp LEFT JOIN transcription_blocks tb ON tb.document_id = d.id GROUP BY d.id, d.title, d.meta_date HAVING COUNT(DISTINCT da.id) > 0 - AND COUNT(DISTINCT CASE WHEN tb.text IS NOT NULL AND tb.text <> '' THEN tb.id END) > 0 AND ( COUNT(DISTINCT CASE WHEN tb.reviewed = true THEN tb.id END)::float / - COUNT(DISTINCT CASE WHEN tb.text IS NOT NULL AND tb.text <> '' THEN tb.id END) + COUNT(DISTINCT da.id) ) >= 0.90 ORDER BY ( COUNT(DISTINCT CASE WHEN tb.reviewed = true THEN tb.id END)::float / - COUNT(DISTINCT CASE WHEN tb.text IS NOT NULL AND tb.text <> '' THEN tb.id END) + COUNT(DISTINCT da.id) ) DESC LIMIT :limit """)