fix(#240): use annotationCount as denominator in queue thresholds
Some checks failed
CI / Unit & Component Tests (pull_request) Failing after 2m24s
CI / Backend Unit Tests (pull_request) Failing after 2m51s
CI / Unit & Component Tests (push) Failing after 2m24s
CI / Backend Unit Tests (push) Failing after 2m37s

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 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-04-16 11:00:18 +02:00
parent ca0cf4903c
commit 8980d810d4

View File

@@ -193,12 +193,9 @@ public interface DocumentRepository extends JpaRepository<Document, UUID>, JpaSp
GROUP BY d.id, d.title, d.meta_date GROUP BY d.id, d.title, d.meta_date
HAVING COUNT(DISTINCT da.id) > 0 HAVING COUNT(DISTINCT da.id) > 0
AND ( AND (
COUNT(DISTINCT CASE WHEN tb.text IS NOT NULL AND tb.text <> '' THEN tb.id END) = 0 COUNT(DISTINCT CASE WHEN tb.reviewed = true THEN tb.id END)::float /
OR ( COUNT(DISTINCT da.id)
COUNT(DISTINCT CASE WHEN tb.reviewed = true THEN tb.id END)::float / ) < 0.90
NULLIF(COUNT(DISTINCT CASE WHEN tb.text IS NOT NULL AND tb.text <> '' THEN tb.id END), 0)
) < 0.90
)
ORDER BY COUNT(DISTINCT CASE WHEN tb.text IS NOT NULL AND tb.text <> '' THEN tb.id END) DESC, 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) HASHTEXT(d.id::text || EXTRACT(WEEK FROM NOW())::int::text)
LIMIT :limit LIMIT :limit
@@ -216,14 +213,13 @@ public interface DocumentRepository extends JpaRepository<Document, UUID>, JpaSp
LEFT JOIN transcription_blocks tb ON tb.document_id = d.id LEFT JOIN transcription_blocks tb ON tb.document_id = d.id
GROUP BY d.id, d.title, d.meta_date GROUP BY d.id, d.title, d.meta_date
HAVING COUNT(DISTINCT da.id) > 0 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 ( AND (
COUNT(DISTINCT CASE WHEN tb.reviewed = true THEN tb.id END)::float / 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 ) >= 0.90
ORDER BY ( ORDER BY (
COUNT(DISTINCT CASE WHEN tb.reviewed = true THEN tb.id END)::float / 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 ) DESC
LIMIT :limit LIMIT :limit
""") """)