mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
Keep only the latest file of a Document Type in each property's folder 🟩
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
28b7b43372
commit
810e910961
1 changed files with 18 additions and 1 deletions
|
|
@ -63,4 +63,21 @@ def plan_download_package(
|
|||
"""Lay out a Download Package from resolved documents (ADR-0060): one folder
|
||||
per property, the latest file of each Document Type, null-Document-Type rows
|
||||
skipped and reported."""
|
||||
raise NotImplementedError
|
||||
latest_by_group: dict[tuple[str, str], ResolvedDocument] = {}
|
||||
for document in documents:
|
||||
assert document.document_type is not None
|
||||
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:
|
||||
latest_by_group[group] = document
|
||||
|
||||
entries: list[PackageEntry] = [
|
||||
PackageEntry(
|
||||
zip_path=f"{document.address} ({document.landlord_property_id})/"
|
||||
f"{document.document_type}",
|
||||
s3_bucket=document.s3_bucket,
|
||||
s3_key=document.s3_key,
|
||||
)
|
||||
for document in latest_by_group.values()
|
||||
]
|
||||
return DownloadPackagePlan(entries=tuple(entries), skipped=())
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue