Merge pull request 'fix(backfill): drop nonexistent kadastr_num column from listings SELECT' (#1732) from fix/backfill-kadastr-column into main
All checks were successful
Deploy Trade-In / changes (push) Successful in 6s
Deploy Trade-In / test (push) Successful in 34s
Deploy Trade-In / build-frontend (push) Has been skipped
Deploy Trade-In / build-browser (push) Has been skipped
Deploy Trade-In / build-backend (push) Successful in 51s
Deploy Trade-In / deploy (push) Successful in 43s

This commit is contained in:
lekss361 2026-06-17 20:53:26 +00:00
commit 6d3fad6b96
2 changed files with 12 additions and 6 deletions

View file

@ -118,7 +118,6 @@ class ListingRow:
year_built: int | None
cadastral_number: str | None
building_cadastral_number: str | None
kadastr_num: str | None
house_source: str | None
house_ext_id: str | None
house_url: str | None
@ -152,7 +151,7 @@ class Stats:
_LISTING_COLUMNS = (
"id, source, source_id, source_url, dedup_hash, "
"address, lat, lon, rooms, area_m2, floor, price_rub, year_built, "
"cadastral_number, building_cadastral_number, kadastr_num, "
"cadastral_number, building_cadastral_number, "
"house_source, house_ext_id, house_url, house_id_fk"
)
@ -217,7 +216,6 @@ def _fetch_batch(
year_built=r["year_built"],
cadastral_number=r["cadastral_number"],
building_cadastral_number=r["building_cadastral_number"],
kadastr_num=r["kadastr_num"],
house_source=r["house_source"],
house_ext_id=r["house_ext_id"],
house_url=r["house_url"],
@ -294,7 +292,7 @@ def _link_listing_to_house(
lon=row.lon,
year_built=row.year_built,
building_cadastral_number=row.building_cadastral_number,
cadastral_number=row.cadastral_number or row.kadastr_num,
cadastral_number=row.cadastral_number,
source_url=row.house_url or row.source_url,
)
house_resolved = house_id is not None

View file

@ -66,7 +66,6 @@ def _row(**overrides) -> ListingRow:
"year_built": 2010,
"cadastral_number": None,
"building_cadastral_number": None,
"kadastr_num": None,
"house_source": None,
"house_ext_id": None,
"house_url": None,
@ -147,7 +146,6 @@ def _row_dict(row: ListingRow) -> dict:
"year_built": row.year_built,
"cadastral_number": row.cadastral_number,
"building_cadastral_number": row.building_cadastral_number,
"kadastr_num": row.kadastr_num,
"house_source": row.house_source,
"house_ext_id": row.house_ext_id,
"house_url": row.house_url,
@ -211,6 +209,16 @@ def test_select_sql_filters_by_source_when_provided():
assert "source = :source" in sql
def test_select_sql_has_no_dropped_kadastr_num_column():
"""`listings.kadastr_num` was dropped in 094_cadastral_unify.sql — the SELECT
must not reference it or psycopg raises UndefinedColumn on every run."""
sql = _build_select_sql(source=None, batch_size=500)
assert "kadastr_num" not in sql
# The canonical apartment-level cadastral columns remain.
assert "cadastral_number" in sql
assert "building_cadastral_number" in sql
# ---------------------------------------------------------------------------
# Happy path — one listing → 1 link + 1 house resolution
# ---------------------------------------------------------------------------