global Extractions für region capacities monthly and weekdays eingefügt, closes #15

main
mmaurostoffel 2025-01-15 20:44:16 +01:00
parent 0733709366
commit 7e3862a578
3 changed files with 27 additions and 2 deletions

View File

@ -497,6 +497,21 @@ class Database:
extractions.created_at < '{scrape_date_max}' extractions.created_at < '{scrape_date_max}'
""") """)
def singleScrape_of_global_scrapDate(self, scrape_date_min: str, scrape_date_max: str):
return self.connection.sql(f"""
SELECT
JSON_EXTRACT(body, '$.content.days') as calendarBody,
extractions.created_at
FROM
consultancy_d.extractions
LEFT JOIN
consultancy_d.properties ON properties.id = extractions.property_id
WHERE
type == 'calendar' AND
extractions.created_at >= '{scrape_date_min}' AND
extractions.created_at < '{scrape_date_max}'
""")
def capacity_global(self): def capacity_global(self):
return self.connection.sql(f""" return self.connection.sql(f"""
SELECT SELECT

View File

@ -22,7 +22,12 @@ def region_capacities_monthly(id: int, scrapeDate_start: str):
# Get end date of start search-window # Get end date of start search-window
scrapeDate_end = scrapeDate_start + timedelta(days=1) scrapeDate_end = scrapeDate_start + timedelta(days=1)
extractions = d.singleScrape_of_region_scrapDate(id, scrapeDate_start, scrapeDate_end).pl() # Get Data
if id == -1:
extractions = d.singleScrape_of_global_scrapDate(scrapeDate_start, scrapeDate_end).pl()
else:
extractions = d.singleScrape_of_region_scrapDate(id, scrapeDate_start, scrapeDate_end).pl()
df_calendar = pl.DataFrame() df_calendar = pl.DataFrame()
numWeeks = 0 numWeeks = 0
firstExe = True firstExe = True

View File

@ -21,7 +21,12 @@ def region_capacities_weekdays(id: int, scrapeDate_start: str):
# Get end date of start search-window # Get end date of start search-window
scrapeDate_end = scrapeDate_start + timedelta(days=1) scrapeDate_end = scrapeDate_start + timedelta(days=1)
extractions = d.singleScrape_of_region_scrapDate(id, scrapeDate_start, scrapeDate_end).pl() # Get Data
if id == -1:
extractions = d.singleScrape_of_global_scrapDate(scrapeDate_start, scrapeDate_end).pl()
else:
extractions = d.singleScrape_of_region_scrapDate(id, scrapeDate_start, scrapeDate_end).pl()
df_calendar = pl.DataFrame() df_calendar = pl.DataFrame()
numWeeks = 0 numWeeks = 0
firstExe = True firstExe = True