Describe the bug
utils/data_loader.py declares a module-level cache variable and a clear_cache() function, but load_all_projects() never reads from or writes to the cache:
_projects_cache = None # declared but never read
def load_all_projects():
with open(DATA_FILE, "r", encoding="utf-8") as f:
return json.load(f) # ← no cache check, file read every call
This means every call to /api/recommend, every project detail page load (find_project_by_id), and every homepage render (get_project_stats) triggers a full disk read and JSON parse. clear_cache() resets a variable that is never read — it is a dead function.
Expected behavior
load_all_projects() should check the cache first and only read the file on a miss.
Suggested fix
def load_all_projects():
global _projects_cache
if _projects_cache is None:
with open(DATA_FILE, "r", encoding="utf-8") as f:
_projects_cache = json.load(f)
return _projects_cache
Files affected
Describe the bug
utils/data_loader.pydeclares a module-level cache variable and aclear_cache()function, butload_all_projects()never reads from or writes to the cache:This means every call to
/api/recommend, every project detail page load (find_project_by_id), and every homepage render (get_project_stats) triggers a full disk read and JSON parse.clear_cache()resets a variable that is never read — it is a dead function.Expected behavior
load_all_projects()should check the cache first and only read the file on a miss.Suggested fix
Files affected
utils/data_loader.py