fix: supply gap inflation + inline map data + guard API endpoints
A. location_profiles.sql: supply gap now uses GREATEST(catchment_padel_courts,
COALESCE(city_padel_venue_count, 0)) so Playtomic venues prevent cities like
Murcia/Cordoba/Gijon from receiving a full 30-pt supply gap bonus when their
OSM catchment count is zero. Expected ~10-15 pt drop for affected ES cities.
B. pseo_country_overview.sql: add population-weighted lat/lon centroid columns
so the markets map can use accurate country positions from this table.
C/D. content/routes.py + markets.html: query pseo_country_overview in the route
and pass as map_countries to the template, replacing the fetch('/api/...') call
with inline JSON. Map scores now match pseo_country_overview (pop-weighted),
and the page loads without an extra round-trip.
E. api.py: add @login_required to all 4 endpoints. Unauthenticated callers get
a 302 redirect to login instead of data.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -37,6 +37,8 @@ SELECT
|
||||
-- Use the most common currency in the country (MIN is deterministic for single-currency countries)
|
||||
MIN(price_currency) AS price_currency,
|
||||
SUM(population) AS total_population,
|
||||
ROUND(SUM(lat * population) / NULLIF(SUM(population), 0), 4) AS lat,
|
||||
ROUND(SUM(lon * population) / NULLIF(SUM(population), 0), 4) AS lon,
|
||||
CURRENT_DATE AS refreshed_date
|
||||
FROM serving.pseo_city_costs_de
|
||||
GROUP BY country_code, country_name_en, country_slug
|
||||
|
||||
Reference in New Issue
Block a user