From 8dda9e0a050547095d13eba2fbe8e11d6446e615 Mon Sep 17 00:00:00 2001 From: Belissimo_T Date: Wed, 22 Nov 2023 20:17:38 +0100 Subject: [PATCH 1/2] add date field to PlanDownload event --- backend/events.py | 1 + backend/plan_downloader.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/events.py b/backend/events.py index 4d1c653..fc92939 100644 --- a/backend/events.py +++ b/backend/events.py @@ -27,6 +27,7 @@ def get_base_dict(self): @dataclasses.dataclass class PlanDownload(Event): plan_type: str # Ex: "PlanKl.xml" or "VPlanKl.xml" + date: datetime.date last_modified: datetime.datetime file_length: int diff --git a/backend/plan_downloader.py b/backend/plan_downloader.py index 06a3492..2464a64 100644 --- a/backend/plan_downloader.py +++ b/backend/plan_downloader.py @@ -148,7 +148,7 @@ async def download_indiware_mobil( ) await timer.submit_async(plan_type=plan_filename, last_modified=plan_response.last_modified, - file_length=len(plan_response.content)) + file_length=len(plan_response.content), date=date) self.cache.store_plan_file(date, revision, plan_response.content, plan_filename) self.cache.store_plan_file(date, revision, json.dumps(downloaded_file.serialize()), From a728816dcd98dce15f33402a0eab43e4dfdc946b Mon Sep 17 00:00:00 2001 From: Belissimo_T Date: Wed, 22 Nov 2023 20:17:59 +0100 Subject: [PATCH 2/2] fix aiohttp client session warnings --- backend/load_plans.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/load_plans.py b/backend/load_plans.py index 6da3483..7c040a8 100644 --- a/backend/load_plans.py +++ b/backend/load_plans.py @@ -89,14 +89,14 @@ async def get_crawlers(session: aiohttp.ClientSession | None = None, ) hosting = Hosting.deserialize(data["hosting"]) - client = IndiwareStundenplanerClient(hosting, session) - if hosting.creds is not None and hosting.creds.username == "schueler": logger.warning("* Disabling room and teacher plans because only student creds are available.") # avoid trying to fetch room and teacher plans if no creds are available - client.teacher_plan_client = None - client.room_plan_client = None - client.teachers_substitution_plan_client = None + hosting.indiware_mobil.rooms = None + hosting.indiware_mobil.teachers = None + hosting.substitution_plan.teachers = None + + client = IndiwareStundenplanerClient(hosting, session) for plan_client in client.substitution_plan_clients: plan_client.proxy_provider = proxy_provider