diff --git a/etl/src/api/main.py b/etl/src/api/main.py index f853e57..0deea18 100644 --- a/etl/src/api/main.py +++ b/etl/src/api/main.py @@ -5,8 +5,8 @@ from data import etl_property_capacities_monthly as etl_pcm from data import etl_property_capacities_weekdays as etl_pcw from data import etl_property_neighbours as etl_pn from data import etl_region_capacities as etl_rc -from data import etl_region_properties_capacities as etl_rpc from data import etl_region_capacities_comparison as etl_rcc +from data import etl_region_properties_capacities as etl_rpc from fastapi import FastAPI, Response d = data.load() @@ -70,6 +70,10 @@ def region_property_capacities_data(id: int): capacities = etl_rpc.region_properties_capacities(id) return capacities +@app.get("/region/{id}/base") +def region_base_data(id: int): + return d.region_base_data(id).pl().to_dicts() + @app.get("/region/{id}/capacities") def region_capacities_data(id: int): capacities = etl_rc.region_capacities(id) diff --git a/etl/src/data/database.py b/etl/src/data/database.py index b8f322f..2d937b2 100644 --- a/etl/src/data/database.py +++ b/etl/src/data/database.py @@ -410,6 +410,20 @@ class Database: p.id = {id} """) + def region_base_data(self, id): + if id == -1: + where = '' + else: + where = f"WHERE r.id = {id}" + return self.connection.sql(f""" + SELECT + r.id as region_id, + r.name as region_name + FROM + consultancy_d.regions r + {where} + """) + def properties_geo(self): return self.connection.sql(""" SELECT