From f6115161bf68b7a6a237b610f4e98bbac173b149 Mon Sep 17 00:00:00 2001 From: Belissimo_T Date: Sun, 10 Mar 2024 19:26:42 +0100 Subject: [PATCH 1/5] remove period after weekday abbreviation --- client/src/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/utils.js b/client/src/utils.js index 21a40c5d..3418d12d 100644 --- a/client/src/utils.js +++ b/client/src/utils.js @@ -356,7 +356,7 @@ export function format_date(date) { const monthIndex = date.getMonth(); const year = date.getFullYear(); - return `${weekday}., ${day}. ${months[monthIndex]} ${year}`; + return `${weekday}, ${day}. ${months[monthIndex]} ${year}`; } From a1839aaa8ef0dce765168ac3b2c44c8724fcbc2e Mon Sep 17 00:00:00 2001 From: Belissimo_T Date: Sun, 10 Mar 2024 19:38:36 +0100 Subject: [PATCH 2/5] expose last fetch in api --- endpoints/api.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/endpoints/api.py b/endpoints/api.py index 79f4dfab..677be5af 100644 --- a/endpoints/api.py +++ b/endpoints/api.py @@ -97,6 +97,20 @@ def plan(school_num: str) -> Response: return send_success(data) +@api.route(f"{API_BASE_URL}/last_fetch", methods=["GET"], endpoint="last_fetch_api") +@login_required +@school_authorized +def last_fetched(school_num: str) -> Response: + if school_num not in VALID_SCHOOLS: + return send_error("Schulnummer unbekannt") + + cache = shared.cache.Cache(Path(".cache") / school_num) + + return send_success(json.loads( + cache.get_meta_file("last_fetch.json") + )) + + @api.route(f"{API_BASE_URL}/authorize", methods=["POST"]) @login_required def authorize(school_num: str) -> Response: From 6e28848d0518cc446636382672b244be93f59777 Mon Sep 17 00:00:00 2001 From: Belissimo_T Date: Sun, 10 Mar 2024 20:02:29 +0100 Subject: [PATCH 3/5] move last_fetch info to plan endpoint --- endpoints/api.py | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/endpoints/api.py b/endpoints/api.py index 677be5af..d841142e 100644 --- a/endpoints/api.py +++ b/endpoints/api.py @@ -90,6 +90,7 @@ def plan(school_num: str) -> Response: "plans": json.loads(cache.get_plan_file(date, revision, "plans.json")), "exams": json.loads(cache.get_plan_file(date, revision, "exams.json")), "grouped_form_plans": json.loads(cache.get_plan_file(date, revision, "grouped_form_plans.json")), + "last_fetch": json.loads(cache.get_meta_file("last_fetch.json"))["timestamp"] } except FileNotFoundError: return send_error("Invalid date or revision.") @@ -97,20 +98,6 @@ def plan(school_num: str) -> Response: return send_success(data) -@api.route(f"{API_BASE_URL}/last_fetch", methods=["GET"], endpoint="last_fetch_api") -@login_required -@school_authorized -def last_fetched(school_num: str) -> Response: - if school_num not in VALID_SCHOOLS: - return send_error("Schulnummer unbekannt") - - cache = shared.cache.Cache(Path(".cache") / school_num) - - return send_success(json.loads( - cache.get_meta_file("last_fetch.json") - )) - - @api.route(f"{API_BASE_URL}/authorize", methods=["POST"]) @login_required def authorize(school_num: str) -> Response: From a2fab172f0577240535f3f4e1e769663fe299500 Mon Sep 17 00:00:00 2001 From: Belissimo_T Date: Sun, 10 Mar 2024 20:13:05 +0100 Subject: [PATCH 4/5] improve form regex --- backend/vplan_utils.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/backend/vplan_utils.py b/backend/vplan_utils.py index 5fdd96ee..e4d15a17 100644 --- a/backend/vplan_utils.py +++ b/backend/vplan_utils.py @@ -10,17 +10,21 @@ _parse_form_pattern = re.compile( r"(?\d{1,2}(?!\d)|[A-Za-zÄÖÜäöüß]+(?![A-Za-zÄÖÜäöüß]))" - r"(?P[/.] |[^A-Za-zÄÖÜäöüß0-9() \n]?)" - r"(?P(?:\d{1,2}[A-Za-zÄÖÜäöüß]?|[A-Za-zÄÖÜäöüß]+?)(?:,(?:\d{1,2}[A-Za-zÄÖÜäöüß]?|[A-Za-zÄÖÜäöüß]+?))*)" - r"|(?P\d{1,2})" + r"(?P |[/._]|[^A-Za-zÄÖÜäöüß0-9() \n]?)(?:(?" + r"(?:\d{1,2}[A-Za-zÄÖÜäöüß]?|[A-Za-zÄÖÜäöüß]+\d{0,2})" + r"(?:,(?:\d{1,2}[A-Za-zÄÖÜäöüß]?|[A-Za-zÄÖÜäöüß]+\d{0,2}))*" + r")|(?P\d{1,2})" r")(?![^\s,:])" ) _loose_parse_form_pattern = re.compile( r"(?\d{1,2}(?!\d)|[A-Za-zÄÖÜäöüß]+(?![A-Za-zÄÖÜäöüß]))" - r"(?P[/.]? |[^A-Za-zÄÖÜäöüß0-9() \n]?)" - r"(?P(?:\d{1,2}[A-Za-zÄÖÜäöüß]?|[A-Za-zÄÖÜäöüß]+?)(?:,(?:\d{1,2}[A-Za-zÄÖÜäöüß]?|[A-Za-zÄÖÜäöüß]+?))*)" - r"|(?P\d{1,2})" + r"(?P |[/._]|[^A-Za-zÄÖÜäöüß0-9() \n]?)(?:(?" + r"(?:\d{1,2}[A-Za-zÄÖÜäöüß]?|[A-Za-zÄÖÜäöüß]+\d{0,2})" + r"(?:,(?:\d{1,2}[A-Za-zÄÖÜäöüß]?|[A-Za-zÄÖÜäöüß]+\d{0,2}))*" + r")|(?P\d{1,2})" r")(?![^\s,:()])" ) From 4c6b589abe2a686b876f0448a893b44488c6d8c9 Mon Sep 17 00:00:00 2001 From: Belissimo_T Date: Sun, 10 Mar 2024 20:29:06 +0100 Subject: [PATCH 5/5] fix type annotation --- backend/plan_processor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/plan_processor.py b/backend/plan_processor.py index 24162891..324ff2f6 100644 --- a/backend/plan_processor.py +++ b/backend/plan_processor.py @@ -312,7 +312,7 @@ def update_forms(self): def update_rooms(self): self._logger.info("* Updating rooms...") - parsed_rooms: dict[str, dict] = {room: None for room in self.meta_extractor.rooms()} + parsed_rooms: dict[str, dict | None] = {room: None for room in self.meta_extractor.rooms()} try: room_parser = schools.room_parsers[str(self.school_number)] except KeyError: