parent
2a9ef9d991
commit
03e78a4105
|
@ -416,5 +416,19 @@ class Database:
|
|||
properties.seed_id = {region_id}
|
||||
""")
|
||||
|
||||
def capacity_global(self):
|
||||
return self.connection.sql(f"""
|
||||
SELECT
|
||||
JSON_EXTRACT(body, '$.content.days') as calendarBody,
|
||||
strftime(extractions.created_at, '%Y-%m-%d') AS ScrapeDate,
|
||||
extractions.property_id,
|
||||
FROM
|
||||
consultancy_d.extractions
|
||||
LEFT JOIN
|
||||
consultancy_d.properties ON properties.id = extractions.property_id
|
||||
WHERE
|
||||
type == 'calendar'
|
||||
""")
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -8,7 +8,10 @@ d = data.load()
|
|||
|
||||
def region_capacities(id: int):
|
||||
# Get Data
|
||||
df = d.capacity_of_region(id).pl()
|
||||
if id == -1:
|
||||
df = d.capacity_global().pl()
|
||||
else:
|
||||
df = d.capacity_of_region(id).pl()
|
||||
# turn PropertyIDs to ints for sorting
|
||||
df = df.cast({"property_id": int})
|
||||
|
||||
|
@ -57,7 +60,4 @@ def region_capacities(id: int):
|
|||
# Create JSON
|
||||
outDict = {'scrapeDates': listOfDates, 'property_ids': listOfPropertyIDs, 'values': gridData}
|
||||
|
||||
return outDict
|
||||
|
||||
out = region_capacities(1)
|
||||
print(out)
|
||||
return outDict
|
Loading…
Reference in New Issue