Issue 1 Beispiel 1 resolved

#1

Globale region capacities eingefügt: Vorsicht! lange Ladezeit
main
mmaurostoffel 2025-01-05 16:12:16 +01:00
parent 2a9ef9d991
commit 03e78a4105
2 changed files with 19 additions and 5 deletions

View File

@ -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'
""")

View File

@ -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})
@ -58,6 +61,3 @@ def region_capacities(id: int):
outDict = {'scrapeDates': listOfDates, 'property_ids': listOfPropertyIDs, 'values': gridData}
return outDict
out = region_capacities(1)
print(out)