mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-27 23:35:01 +00:00
Run a Calico load end to end and return its reconciliation 🟩
run_calico_load ties parse -> map -> persist together: it resolves references to UPRNs, drops blank/unmatched rows, persists the roof-covering surveys with export-year-anchored renewal years, and returns the four-count LoadReport. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a6a48dd337
commit
773869ada4
1 changed files with 26 additions and 2 deletions
|
|
@ -1,8 +1,14 @@
|
|||
from typing import BinaryIO
|
||||
from typing import BinaryIO, List
|
||||
|
||||
from applications.condition.load_report import LoadReport
|
||||
from domain.condition.mapping.calico.calico_mapper import CalicoMapper
|
||||
from domain.condition.property_condition_survey import PropertyConditionSurvey
|
||||
from infrastructure.condition.parsing.calico_parser import CalicoParser
|
||||
from repositories.condition.condition_writer import ConditionWriter
|
||||
from repositories.condition.property_uprn_lookup import PropertyUprnLookup
|
||||
from utils.logger import setup_logger
|
||||
|
||||
logger = setup_logger()
|
||||
|
||||
|
||||
def run_calico_load(
|
||||
|
|
@ -14,4 +20,22 @@ def run_calico_load(
|
|||
"""Parse a Calico export, map each roof-covering observation to a condition
|
||||
survey keyed by UPRN, persist them, and return the reconciliation report
|
||||
(ADR-0064). ``export_year`` anchors renewal years so they don't drift."""
|
||||
raise NotImplementedError
|
||||
parser = CalicoParser(uprn_lookup)
|
||||
properties = parser.parse(file_stream)
|
||||
|
||||
mapper = CalicoMapper()
|
||||
surveys: List[PropertyConditionSurvey] = [
|
||||
mapper.map_asset_conditions_for_property(prop, export_year)
|
||||
for prop in properties
|
||||
]
|
||||
|
||||
writer.bulk_insert_surveys(surveys)
|
||||
|
||||
report = LoadReport.from_calico_load(
|
||||
properties=properties,
|
||||
blank_placeholder_count=parser.blank_placeholder_count,
|
||||
unmatched_reference_count=parser.unmatched_reference_count,
|
||||
null_uprn_references=uprn_lookup.null_uprn_references(),
|
||||
)
|
||||
logger.info(f"[calico_load] {report}")
|
||||
return report
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue