implements regions base endpoint #9
parent
f31c23ea51
commit
0250221d96
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue