feat: track media catalog coverage

This commit is contained in:
ik
2026-09-13 08:14:56 +07:00
parent 674bc5627f
commit 7e464ef598
7 changed files with 65 additions and 4 deletions
+19
View File
@@ -162,6 +162,25 @@ def audit_media_catalog(root: Path) -> dict:
return {"total": sum(statuses.values()), "statuses": statuses, "issues": issues, "orphaned_files": orphaned}
def media_coverage(root: Path) -> dict:
"""Compare quarantined and approved media with the versioned catalog baseline."""
manifest = json.loads((root / "manifest.json").read_text(encoding="utf-8"))
baseline = json.loads((root / "catalog-baseline.json").read_text(encoding="utf-8"))
result: dict[str, dict] = {}
for entity_type, target in baseline["entities"].items():
candidates = [item for item in manifest.get("assets", []) if item.get("entity_type") == entity_type]
approved_keys = {item.get("entity_key") for item in candidates if item.get("status") == "approved" and item.get("entity_key")}
expected = target.get("count")
result[entity_type] = {
"expected": expected,
"candidates": len(candidates),
"approved": len(approved_keys),
"candidate_gap": max(expected - len(candidates), 0) if isinstance(expected, int) else None,
"approved_gap": max(expected - len(approved_keys), 0) if isinstance(expected, int) else None,
}
return {"baseline_date": baseline["verified_at"], "entities": result}
def inspect_image(body: bytes) -> tuple[int, int, str]:
try:
with Image.open(io.BytesIO(body)) as image: