Drop property-table wiring for certificate_number

On reflection the certificate number only needs to travel through the
address2uprn pipeline (result CSV, S3 output) as an internal value —
not persisted to property. Reverts the PropertyIdentityInsert /
property_table.py / property_postgres_repository.py changes; keeps
certificate_number flowing through get_epc_data_with_postcode,
get_uprn_with_epc_df, get_uprn_from_historic_epc, and the
address2uprn_certificate_number result column.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Jun-te Kim 2026-07-07 14:16:55 +00:00
parent 3718743801
commit 7abc71ed95
5 changed files with 2 additions and 18 deletions

View file

@ -49,7 +49,6 @@ class PropertyRow(SQLModel, table=True):
user_inputted_address: Optional[str] = Field(default=None)
user_inputted_postcode: Optional[str] = Field(default=None)
lexiscore: Optional[float] = Field(default=None)
certificate_number: Optional[str] = Field(default=None)
# FE-owned columns the modelling pipeline now WRITES to record a run: the old
# engine set `has_recommendations` (engine.py); we mirror that, and bump

View file

@ -41,7 +41,6 @@ INTERNAL_REF_COL = "Internal Reference"
UPRN_COL = "address2uprn_uprn"
MATCHED_ADDRESS_COL = "address2uprn_address"
LEXISCORE_COL = "address2uprn_lexiscore"
CERTIFICATE_NUMBER_COL = "address2uprn_certificate_number"
MISSING_SENTINEL = "invalid postcode"
UK_POSTCODE_RE = re.compile(r"[A-Z]{1,2}\d[A-Z\d]?\s*\d[A-Z]{2}", re.IGNORECASE)
@ -363,11 +362,6 @@ class BulkUploadFinaliserOrchestrator:
internal_ref = _normalize(raw.get(INTERNAL_REF_COL)) or None
lexiscore = _parse_lexiscore(raw.get(LEXISCORE_COL))
certificate_number_raw = _normalize(raw.get(CERTIFICATE_NUMBER_COL))
certificate_number = (
None if _is_missing(certificate_number_raw) else certificate_number_raw
)
return PropertyIdentityInsert(
portfolio_id=portfolio_id,
uprn=uprn,
@ -377,6 +371,5 @@ class BulkUploadFinaliserOrchestrator:
user_inputted_address=user_inputted_address,
user_inputted_postcode=user_inputted_postcode,
lexiscore=lexiscore,
certificate_number=certificate_number,
creation_status="READY",
)

View file

@ -162,7 +162,6 @@ class PropertyPostgresRepository(PropertyRepository):
"user_inputted_address": r.user_inputted_address,
"user_inputted_postcode": r.user_inputted_postcode,
"lexiscore": r.lexiscore,
"certificate_number": r.certificate_number,
}
for r in rows
]

View file

@ -13,10 +13,8 @@ class PropertyIdentityInsert:
"""One row inserted into the FE-owned ``property`` table at Finalise (ADR-0013).
Mirrors the exact column set today's Next.js ``/finalize`` writes: nine fields
plus ``creation_status='READY'``, plus ``certificate_number`` (the EPC
certificate the address2uprn lookup matched, not written by the old
Next.js route). ``address``/``postcode`` are the resolved (matched ??
user-inputted) values and may be ``None``.
plus ``creation_status='READY'``. ``address``/``postcode`` are the resolved
(matched ?? user-inputted) values and may be ``None``.
"""
portfolio_id: int
@ -27,7 +25,6 @@ class PropertyIdentityInsert:
user_inputted_address: Optional[str]
user_inputted_postcode: Optional[str]
lexiscore: Optional[float]
certificate_number: Optional[str] = None
creation_status: str = "READY"

View file

@ -100,7 +100,6 @@ def test_finalise_inserts_resolved_rows_and_marks_complete() -> None:
"address2uprn_uprn": "100023",
"address2uprn_address": "1 SOME STREET, TOWN, SW1A 1AA",
"address2uprn_lexiscore": "0.95",
"address2uprn_certificate_number": "1234-5678-9012-3456-7890",
},
]
@ -115,7 +114,6 @@ def test_finalise_inserts_resolved_rows_and_marks_complete() -> None:
assert row.postcode == "SW1A 1AA" # extracted from the matched address
assert row.user_inputted_address == "1 Some Street"
assert row.lexiscore == 0.95
assert row.certificate_number == "1234-5678-9012-3456-7890"
assert row.creation_status == "READY"
# The upload is marked complete via the injected status writer.
assert status.calls == [(task_id, "complete")]
@ -130,7 +128,6 @@ def test_finalise_falls_back_to_user_input_when_unmatched() -> None:
"address2uprn_uprn": "invalid postcode",
"address2uprn_address": "invalid postcode",
"address2uprn_lexiscore": "",
"address2uprn_certificate_number": "invalid postcode",
},
]
@ -141,7 +138,6 @@ def test_finalise_falls_back_to_user_input_when_unmatched() -> None:
assert row.address == "2 Other Road" # falls back to user input
assert row.postcode == "B1 1BB" # falls back to user-inputted postcode
assert row.lexiscore is None
assert row.certificate_number is None # missing sentinel -> None
def test_finalise_parses_pandas_float_uprn() -> None: