fix(worker): mark ingested assets ready
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user