Python 67%
TypeScript 18.2%
CSS 14.4%
1#!/usr/bin/env python32# -----------------------------------------------------------------------------3# House-Ka — one-shot migration (2026-08-27, kept for reference)4# scripts/migrate_types_en.py :5# 1. translates the historical French canonical property types to English;6# 2. derives the missing property_type from the DDF `details` fields7# ("Building Type" / "Property Type") via normalize_property_type;8# 3. recomputes dedup + quality (publication) for the whole base.9# Run from the repo root: .venv/bin/python scripts/migrate_types_en.py10# -----------------------------------------------------------------------------11import json12import sys13from pathlib import Path1415sys.path.insert(0, str(Path(__file__).resolve().parent.parent))1617from immoka import db, quality18from immoka.normalize import normalize_property_type1920FR_TO_EN = {21 "Maison": "House", "Maison mobile": "Mobile home", "Jumelé": "Semi-detached",22 "Maison de ville": "Townhouse", "Multiplex": "Multi-family",23 "Chalet": "Cottage", "Terrain": "Land", "Fermette/Agricole": "Farm",24}2526con = db.connect()2728# 1. FR -> EN on the existing canonical values29for fr, en in FR_TO_EN.items():30 n = con.execute("UPDATE listings SET property_type=? WHERE property_type=?",31 (en, fr)).rowcount32 if n:33 print(f"{fr} -> {en}: {n}")34con.commit()3536# 2. derive the type from details for rows without one37updates = []38for r in con.execute("SELECT uid, details FROM listings"39 " WHERE (property_type IS NULL OR property_type='')"40 " AND details LIKE '%Type%'"):41 try:42 d = json.loads(r["details"] or "{}")43 except ValueError:44 continue45 raw = d.get("Building Type") or d.get("Property Type") or d.get("Type")46 if not raw:47 continue48 pt = normalize_property_type(str(raw))49 if pt:50 updates.append((pt, r["uid"]))51if updates:52 con.executemany("UPDATE listings SET property_type=? WHERE uid=?", updates)53 con.commit()54print(f"derived from details: {len(updates)}")5556# 3. dedup + quality (publication rule: price + city)57hidden = db.refresh_dedup(con)58print(f"dedup: {hidden} hidden")59q = quality.refresh(con)60print(f"quality: {q}")61con.execute("PRAGMA optimize")62con.close()63