From 3f6e65b9da552d441a27dc60e763cc8116a6fac7 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Fri, 5 Apr 2024 11:00:01 +0200 Subject: [PATCH] =?UTF-8?q?Elimine=20@cached=5Fproperty=20sur=20Identite,?= =?UTF-8?q?=20pourrait=20provoquer=20incoh=C3=A9rences=20temporaires=20en?= =?UTF-8?q?=20multithread?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/etudiants.py | 2 +- app/models/formsemestre.py | 2 +- app/scodoc/sco_cache.py | 19 ++++++++----------- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/app/models/etudiants.py b/app/models/etudiants.py index f79264c5..61fd3e23 100644 --- a/app/models/etudiants.py +++ b/app/models/etudiants.py @@ -297,7 +297,7 @@ class Identite(models.ScoDocModel): else: return self.nom - @cached_property + @property def nomprenom(self, reverse=False) -> str: """Civilité/nom/prenom pour affichages: "M. Pierre Dupont" Si reverse, "Dupont Pierre", sans civilité. diff --git a/app/models/formsemestre.py b/app/models/formsemestre.py index 1799c603..c3623bb3 100644 --- a/app/models/formsemestre.py +++ b/app/models/formsemestre.py @@ -945,7 +945,7 @@ class FormSemestre(models.ScoDocModel): ins.etudid for ins in self.inscriptions if ins.etat == scu.INSCRIT } - @cached_property + @property def etuds_inscriptions(self) -> dict: """Map { etudid : inscription } (incluant DEM et DEF)""" return {ins.etud.id: ins for ins in self.inscriptions} diff --git a/app/scodoc/sco_cache.py b/app/scodoc/sco_cache.py index ddb8eb3c..677dae6c 100644 --- a/app/scodoc/sco_cache.py +++ b/app/scodoc/sco_cache.py @@ -55,7 +55,6 @@ from flask import g import app from app import db, log -from app.scodoc import notesdb as ndb from app.scodoc import sco_utils as scu from app.scodoc.sco_exceptions import ScoException @@ -174,17 +173,15 @@ class EvaluationCache(ScoDocCache): @classmethod def invalidate_all_sems(cls): "delete all evaluations in current dept from cache" + from app.models.evaluations import Evaluation + from app.models.formsemestre import FormSemestre + from app.models.moduleimpls import ModuleImpl + evaluation_ids = [ - x[0] - for x in ndb.SimpleQuery( - """SELECT e.id - FROM notes_evaluation e, notes_moduleimpl mi, notes_formsemestre s - WHERE s.dept_id=%(dept_id)s - AND s.id = mi.formsemestre_id - AND mi.id = e.moduleimpl_id; - """, - {"dept_id": g.scodoc_dept_id}, - ) + e.id + for e in Evaluation.query.join(ModuleImpl) + .join(FormSemestre) + .filter_by(dept_id=g.scodoc_dept_id) ] cls.delete_many(evaluation_ids)