mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-19 17:03:02 +00:00
Treat a selection with no documents as a recorded failure 🟩
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
73b21e8d64
commit
59ef8a12ab
1 changed files with 18 additions and 0 deletions
|
|
@ -21,6 +21,7 @@ from domain.bulk_document_download.package_plan import (
|
||||||
SkippedDocument,
|
SkippedDocument,
|
||||||
plan_download_package,
|
plan_download_package,
|
||||||
)
|
)
|
||||||
|
from domain.tasks.subtasks import SubTaskFailure
|
||||||
from infrastructure.postgres.uploaded_file_table import UploadedFile
|
from infrastructure.postgres.uploaded_file_table import UploadedFile
|
||||||
from infrastructure.s3.s3_client import S3Client
|
from infrastructure.s3.s3_client import S3Client
|
||||||
from repositories.email.email_sender import EmailSender
|
from repositories.email.email_sender import EmailSender
|
||||||
|
|
@ -81,6 +82,23 @@ class BulkDocumentDownloadOrchestrator:
|
||||||
resolved = [self._resolve(file) for file in files]
|
resolved = [self._resolve(file) for file in files]
|
||||||
plan = plan_download_package([r for r in resolved if r is not None])
|
plan = plan_download_package([r for r in resolved if r is not None])
|
||||||
|
|
||||||
|
if not plan.entries:
|
||||||
|
# Nothing to package (ADR-0060): a recorded failure, not an empty
|
||||||
|
# ZIP emailed to the user. The skip detail rides on the failure.
|
||||||
|
raise SubTaskFailure(
|
||||||
|
"no documents resolved for the selection",
|
||||||
|
details={
|
||||||
|
"skipped": [
|
||||||
|
{
|
||||||
|
"landlord_property_id": s.landlord_property_id,
|
||||||
|
"s3_key": s.s3_key,
|
||||||
|
"reason": s.reason,
|
||||||
|
}
|
||||||
|
for s in plan.skipped
|
||||||
|
]
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
buffer = io.BytesIO()
|
buffer = io.BytesIO()
|
||||||
with zipfile.ZipFile(buffer, "w", zipfile.ZIP_DEFLATED) as archive:
|
with zipfile.ZipFile(buffer, "w", zipfile.ZIP_DEFLATED) as archive:
|
||||||
for entry in plan.entries:
|
for entry in plan.entries:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue