diff --git a/apps/worker/worker_app/tasks/ingest.py b/apps/worker/worker_app/tasks/ingest.py index fc5d6df33..babb9a53b 100644 --- a/apps/worker/worker_app/tasks/ingest.py +++ b/apps/worker/worker_app/tasks/ingest.py @@ -7,7 +7,7 @@ from packages.adapters.sqlalchemy_impl import ( SQLAlchemyAssetRepository, SQLAlchemyIngestJobRepository, ) -from packages.domain import Asset, IngestJobStatus +from packages.domain import Asset, AssetStatus, IngestJobStatus from worker_app.core.asset_types import infer_mime_type_from_storage_key @@ -56,6 +56,11 @@ def ingest_asset(job_id: str) -> dict: storage_key=job.storage_key, mime_type=mime_type, metadata=metadata, + file_size=int(metadata["size_bytes"]), + duration=float(metadata["duration"]), + width=int(metadata["width"]), + height=int(metadata["height"]), + status=AssetStatus.READY, ) asset_repo.create(asset) diff --git a/tests/unit/test_worker_ingest_status.py b/tests/unit/test_worker_ingest_status.py new file mode 100644 index 000000000..501d353d9 --- /dev/null +++ b/tests/unit/test_worker_ingest_status.py @@ -0,0 +1,9 @@ +from pathlib import Path + + +def test_ingest_marks_created_assets_ready_with_size_metadata(): + source = Path("apps/worker/worker_app/tasks/ingest.py").read_text(encoding="utf-8") + + assert "status=AssetStatus.READY" in source + assert "file_size=int(metadata[\"size_bytes\"])" in source + assert "duration=float(metadata[\"duration\"])" in source