Model/applications/condition/load_report.py
Khalim Conn-Kowlessar 75c561e9db Summarise a Calico load as a four-count reconciliation report 🟩
LoadReport.from_calico_load reports loaded observations alongside the three drop
reasons (unmatched-to-portfolio, null-uprn, blank-placeholder) so every Calico
row is accounted for.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-13 15:10:08 +00:00

31 lines
952 B
Python

from dataclasses import dataclass
from typing import List
from domain.condition.records.calico.calico_property import CalicoProperty
@dataclass(frozen=True)
class LoadReport:
"""The reconciliation a Calico load emits so nothing vanishes silently
(ADR-0064): how many observations were loaded versus dropped, and why."""
loaded: int
unmatched_to_portfolio: int
null_uprn: int
blank_placeholder: int
@classmethod
def from_calico_load(
cls,
properties: List[CalicoProperty],
blank_placeholder_count: int,
unmatched_reference_count: int,
null_uprn_references: List[str],
) -> "LoadReport":
loaded = sum(len(prop.assets) for prop in properties)
return cls(
loaded=loaded,
unmatched_to_portfolio=unmatched_reference_count,
null_uprn=len(null_uprn_references),
blank_placeholder=blank_placeholder_count,
)