refactor(web): update all references to location_profiles

Update api.py (3 endpoints), public/routes.py, analytics.py docstring,
pipeline_routes.py DAG, pipeline_query.html placeholder, and
test_pipeline.py fixtures to use the new unified model.

Subtask 3/5: web app references.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Deeman
2026-03-06 11:41:42 +01:00
parent 81b556b205
commit 688f2dd1ee
6 changed files with 36 additions and 32 deletions

View File

@@ -64,7 +64,7 @@ def serving_meta_dir():
meta = {
"exported_at_utc": "2026-02-25T08:30:00+00:00",
"tables": {
"city_market_profile": {"row_count": 612},
"location_profiles": {"row_count": 612},
"planner_defaults": {"row_count": 612},
"pseo_city_costs_de": {"row_count": 487},
},
@@ -78,16 +78,16 @@ def serving_meta_dir():
# ── Schema + query mocks ──────────────────────────────────────────────────────
_MOCK_SCHEMA_ROWS = [
{"table_name": "city_market_profile", "column_name": "city_slug", "data_type": "VARCHAR", "ordinal_position": 1},
{"table_name": "city_market_profile", "column_name": "country_code", "data_type": "VARCHAR", "ordinal_position": 2},
{"table_name": "city_market_profile", "column_name": "marktreife_score", "data_type": "DOUBLE", "ordinal_position": 3},
{"table_name": "location_profiles", "column_name": "city_slug", "data_type": "VARCHAR", "ordinal_position": 1},
{"table_name": "location_profiles", "column_name": "country_code", "data_type": "VARCHAR", "ordinal_position": 2},
{"table_name": "location_profiles", "column_name": "market_score", "data_type": "DOUBLE", "ordinal_position": 3},
{"table_name": "planner_defaults", "column_name": "city_slug", "data_type": "VARCHAR", "ordinal_position": 1},
]
_MOCK_TABLE_EXISTS = [{"1": 1}]
_MOCK_SAMPLE_ROWS = [
{"city_slug": "berlin", "country_code": "DE", "marktreife_score": 82.5},
{"city_slug": "munich", "country_code": "DE", "marktreife_score": 77.0},
{"city_slug": "berlin", "country_code": "DE", "market_score": 82.5},
{"city_slug": "munich", "country_code": "DE", "market_score": 77.0},
]
@@ -100,7 +100,7 @@ def _make_fetch_analytics_mock(schema=True):
return [r for r in _MOCK_SCHEMA_ROWS if r["table_name"] == params[0]]
if "information_schema.columns" in sql:
return _MOCK_SCHEMA_ROWS
if "city_market_profile" in sql:
if "location_profiles" in sql:
return _MOCK_SAMPLE_ROWS
return []
return _mock
@@ -162,7 +162,7 @@ async def test_pipeline_overview(admin_client, state_db_dir, serving_meta_dir):
resp = await admin_client.get("/admin/pipeline/overview")
assert resp.status_code == 200
data = await resp.get_data(as_text=True)
assert "city_market_profile" in data
assert "location_profiles" in data
assert "612" in data # row count from serving meta
@@ -314,7 +314,7 @@ async def test_pipeline_catalog(admin_client, serving_meta_dir):
resp = await admin_client.get("/admin/pipeline/catalog")
assert resp.status_code == 200
data = await resp.get_data(as_text=True)
assert "city_market_profile" in data
assert "location_profiles" in data
assert "612" in data # row count from serving meta
@@ -322,7 +322,7 @@ async def test_pipeline_catalog(admin_client, serving_meta_dir):
async def test_pipeline_table_detail(admin_client):
"""Table detail returns columns and sample rows."""
with patch("padelnomics.analytics.fetch_analytics", side_effect=_make_fetch_analytics_mock()):
resp = await admin_client.get("/admin/pipeline/catalog/city_market_profile")
resp = await admin_client.get("/admin/pipeline/catalog/location_profiles")
assert resp.status_code == 200
data = await resp.get_data(as_text=True)
assert "city_slug" in data
@@ -362,7 +362,7 @@ async def test_pipeline_query_editor_loads(admin_client):
data = await resp.get_data(as_text=True)
assert "query-editor" in data
assert "schema-panel" in data
assert "city_market_profile" in data
assert "location_profiles" in data
@pytest.mark.asyncio
@@ -380,7 +380,7 @@ async def test_pipeline_query_execute_valid(admin_client):
with patch("padelnomics.analytics.execute_user_query", new_callable=AsyncMock, return_value=mock_result):
resp = await admin_client.post(
"/admin/pipeline/query/execute",
form={"csrf_token": "test", "sql": "SELECT city_slug, country_code FROM serving.city_market_profile"},
form={"csrf_token": "test", "sql": "SELECT city_slug, country_code FROM serving.location_profiles"},
)
assert resp.status_code == 200
data = await resp.get_data(as_text=True)
@@ -397,7 +397,7 @@ async def test_pipeline_query_execute_blocked_keyword(admin_client):
with patch("padelnomics.analytics.execute_user_query", new_callable=AsyncMock) as mock_q:
resp = await admin_client.post(
"/admin/pipeline/query/execute",
form={"csrf_token": "test", "sql": "DROP TABLE serving.city_market_profile"},
form={"csrf_token": "test", "sql": "DROP TABLE serving.location_profiles"},
)
assert resp.status_code == 200
data = await resp.get_data(as_text=True)
@@ -532,8 +532,8 @@ def test_load_serving_meta(serving_meta_dir):
with patch.object(pipeline_mod, "_SERVING_DUCKDB_PATH", str(Path(serving_meta_dir) / "analytics.duckdb")):
meta = pipeline_mod._load_serving_meta()
assert meta is not None
assert "city_market_profile" in meta["tables"]
assert meta["tables"]["city_market_profile"]["row_count"] == 612
assert "location_profiles" in meta["tables"]
assert meta["tables"]["location_profiles"]["row_count"] == 612
def test_load_serving_meta_missing():