From 5bee6ddc63ee48fcf49a8d9b2fd5304c6da7e455 Mon Sep 17 00:00:00 2001 From: Eliot Date: Fri, 31 Jan 2025 19:18:13 +0100 Subject: [PATCH] feat: scrape modules ids --- app/intranet/intranet_manager.py | 1 + app/main.py | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/intranet/intranet_manager.py b/app/intranet/intranet_manager.py index e4bdfa2..13de81a 100644 --- a/app/intranet/intranet_manager.py +++ b/app/intranet/intranet_manager.py @@ -95,6 +95,7 @@ def fetch_modules_list(self, student: Student): for m in res: ret.append({ "code": m["code"], + "id": int(m["id"]) if "id" in m else None, "scolaryear": m["scolaryear"], "codeinstance": m["codeinstance"], }) diff --git a/app/main.py b/app/main.py index 5413f3b..779bd52 100644 --- a/app/main.py +++ b/app/main.py @@ -55,10 +55,12 @@ def sync_student(self, student): try: all_modules = self.intranet.fetch_modules_list(student) for module in all_modules: - if len([m for m in known_modules if m == module["code"]]) == 0: + if len([m for m in known_modules if m == module["id"]]) == 0: if body["modules"] is None: body["modules"] = [] - body["modules"].append(self.intranet.fetch_module(module["scolaryear"], module["code"], module["codeinstance"], student)) + m = self.intranet.fetch_module(module["scolaryear"], module["code"], module["codeinstance"], student) + m["id"] = module["id"] if "id" in module else None + body["modules"].append(m) except Exception as e: log_error(f"Failed to fetch MyEpitech data for student: {student.student_label}") traceback.print_exc()