Skip and report a document with no Document Type 🟩

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Khalim Conn-Kowlessar 2026-07-08 09:06:26 +00:00
parent 34c48d4adc
commit bd928828e3

View file

@ -64,8 +64,17 @@ def plan_download_package(
per property, the latest file of each Document Type, null-Document-Type rows
skipped and reported."""
latest_by_group: dict[tuple[str, str], ResolvedDocument] = {}
skipped: list[SkippedDocument] = []
for document in documents:
assert document.document_type is not None
if document.document_type is None:
skipped.append(
SkippedDocument(
landlord_property_id=document.landlord_property_id,
s3_key=document.s3_key,
reason="null_document_type",
)
)
continue
group = (document.landlord_property_id, document.document_type)
incumbent = latest_by_group.get(group)
if incumbent is None or document.uploaded_at > incumbent.uploaded_at:
@ -80,4 +89,4 @@ def plan_download_package(
)
for document in latest_by_group.values()
]
return DownloadPackagePlan(entries=tuple(entries), skipped=())
return DownloadPackagePlan(entries=tuple(entries), skipped=tuple(skipped))