Chore: document the page numbering in zone OCR

This commit is contained in:
stumpylog committed 2026-11-20 09:52:58 -08:00
1 parent ad64f2a1b1
commit 6b8b946567
2 files changed
+8 -2

No files matched your search

+4 -1
View File
@@ -5895,7 +5895,10 @@ class OcrTemplateViewSet(BulkPermissionMixin, PassUserMixin, ModelViewSet[OcrTem
doc_id: str,
page: str,
) -> HttpResponse:
"""Render a page for the template editor's zone overlay."""
"""
Render a page for the template editor's zone overlay. The page in the URL is
0-based, unlike a zone's page, which is 1-based.
"""
from documents.zone_ocr import resolve_zone_source
document: Document = get_object_or_404(
+4 -1
View File
@@ -439,7 +439,10 @@ def zone_results_written(results: list[ZoneOcrResult]) -> bool:
def _resolve_page_idx(page_value: int | None, page_count: int | None) -> int:
"""Resolve a 1-based page or -1 (last page), defaulting to the first page."""
"""
Resolve a zone's 1-based page or -1 (last page) to a 0-based index, defaulting
to the first page. Without a page count, the last page resolves to the first.
"""
if page_value == -1:
return max((page_count or 1) - 1, 0)
return max((page_value or 1) - 1, 0)