implements regions base endpoint #9

main
Giò Diani 2025-01-12 20:16:20 +01:00
parent f31c23ea51
commit 0250221d96
2 changed files with 19 additions and 1 deletions

View File

@ -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_capacities_weekdays as etl_pcw
from data import etl_property_neighbours as etl_pn from data import etl_property_neighbours as etl_pn
from data import etl_region_capacities as etl_rc 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_capacities_comparison as etl_rcc
from data import etl_region_properties_capacities as etl_rpc
from fastapi import FastAPI, Response from fastapi import FastAPI, Response
d = data.load() d = data.load()
@ -70,6 +70,10 @@ def region_property_capacities_data(id: int):
capacities = etl_rpc.region_properties_capacities(id) capacities = etl_rpc.region_properties_capacities(id)
return capacities 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") @app.get("/region/{id}/capacities")
def region_capacities_data(id: int): def region_capacities_data(id: int):
capacities = etl_rc.region_capacities(id) capacities = etl_rc.region_capacities(id)

View File

@ -410,6 +410,20 @@ class Database:
p.id = {id} 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): def properties_geo(self):
return self.connection.sql(""" return self.connection.sql("""
SELECT SELECT