Skip to content

Commit

Permalink
fix(backend): remove to database modules without an id set (caused by…
Browse files Browse the repository at this point in the history
… past migration)
  • Loading branch information
EliotAmn committed Feb 1, 2025
1 parent 21c7193 commit 9a17083
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from app.api.routes.settings_routes import load_settings_routes
from app.api.routes.sync_routes import load_sync_routes
from app.globals import Globals
from app.services.module_service import ModuleService
from app.services.mouli_service import MouliService
from app.services.publicscraper_service import PublicScraperService
from app.tools.envloader import load_env
Expand Down Expand Up @@ -102,6 +103,8 @@ def serve(path):
if os.getenv("BYPASS_CACHE_RELOAD", "false") == "false":
MouliService.refresh_all_cache()

ModuleService.purge_nonid_modules()

return flask_app


Expand Down
4 changes: 4 additions & 0 deletions app/services/module_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ def get_latest_fetchdate(student_id: str) -> str:
sort=[("fetch_date", -1)])
return p["fetch_date"] if p else None

@staticmethod
def purge_nonid_modules():
Globals.database["modules"].delete_many({"module_id": {"$exists": False}})

@staticmethod
def upload_module(module: Module):
curr = ModuleService.get_module_by_id(module.student_id, module.module_id)
Expand Down

0 comments on commit 9a17083

Please sign in to comment.