Skip to content

Commit

Permalink
feat: scrape modules ids
Browse files Browse the repository at this point in the history
  • Loading branch information
EliotAmn committed Jan 31, 2025
1 parent 4a31d43 commit 5bee6dd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/intranet/intranet_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
})
Expand Down
6 changes: 4 additions & 2 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 5bee6dd

Please sign in to comment.