Elimine @cached_property sur Identite, pourrait provoquer incohérences temporaires en multithread

This commit is contained in:
Emmanuel Viennet 2024-04-05 11:00:01 +02:00
parent 5eba6170a5
commit 3f6e65b9da
3 changed files with 10 additions and 13 deletions

View File

@ -297,7 +297,7 @@ class Identite(models.ScoDocModel):
else: else:
return self.nom return self.nom
@cached_property @property
def nomprenom(self, reverse=False) -> str: def nomprenom(self, reverse=False) -> str:
"""Civilité/nom/prenom pour affichages: "M. Pierre Dupont" """Civilité/nom/prenom pour affichages: "M. Pierre Dupont"
Si reverse, "Dupont Pierre", sans civilité. Si reverse, "Dupont Pierre", sans civilité.

View File

@ -945,7 +945,7 @@ class FormSemestre(models.ScoDocModel):
ins.etudid for ins in self.inscriptions if ins.etat == scu.INSCRIT ins.etudid for ins in self.inscriptions if ins.etat == scu.INSCRIT
} }
@cached_property @property
def etuds_inscriptions(self) -> dict: def etuds_inscriptions(self) -> dict:
"""Map { etudid : inscription } (incluant DEM et DEF)""" """Map { etudid : inscription } (incluant DEM et DEF)"""
return {ins.etud.id: ins for ins in self.inscriptions} return {ins.etud.id: ins for ins in self.inscriptions}

View File

@ -55,7 +55,6 @@ from flask import g
import app import app
from app import db, log from app import db, log
from app.scodoc import notesdb as ndb
from app.scodoc import sco_utils as scu from app.scodoc import sco_utils as scu
from app.scodoc.sco_exceptions import ScoException from app.scodoc.sco_exceptions import ScoException
@ -174,17 +173,15 @@ class EvaluationCache(ScoDocCache):
@classmethod @classmethod
def invalidate_all_sems(cls): def invalidate_all_sems(cls):
"delete all evaluations in current dept from cache" "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 = [ evaluation_ids = [
x[0] e.id
for x in ndb.SimpleQuery( for e in Evaluation.query.join(ModuleImpl)
"""SELECT e.id .join(FormSemestre)
FROM notes_evaluation e, notes_moduleimpl mi, notes_formsemestre s .filter_by(dept_id=g.scodoc_dept_id)
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},
)
] ]
cls.delete_many(evaluation_ids) cls.delete_many(evaluation_ids)