forked from ScoDoc/ScoDoc
Assiduites : fix compte abs negatif + prob cache
This commit is contained in:
parent
ff92a8f61e
commit
943604996b
@ -656,27 +656,16 @@ def get_assiduites_count_in_interval(
|
||||
|
||||
assiduites: Query = Assiduite.query.filter_by(etudid=etudid)
|
||||
assiduites = assiduites.filter(Assiduite.etat == scu.EtatAssiduite.ABSENT)
|
||||
justificatifs: Justificatif = Justificatif.query.filter_by(etudid=etudid)
|
||||
|
||||
assiduites = filter_by_date(assiduites, Assiduite, date_debut, date_fin)
|
||||
|
||||
if moduleimpl_id is not None:
|
||||
assiduites = assiduites.filter_by(moduleimpl_id=moduleimpl_id)
|
||||
|
||||
justificatifs = filter_by_date(
|
||||
justificatifs, Justificatif, date_debut, date_fin
|
||||
)
|
||||
calculator: CountCalculator = CountCalculator()
|
||||
calculator.compute_assiduites(assiduites)
|
||||
nb_abs: dict = calculator.to_dict()[metrique]
|
||||
|
||||
abs_just: list[Assiduite] = get_all_justified(
|
||||
etudid, date_debut, date_fin, moduleimpl_id
|
||||
)
|
||||
|
||||
calculator.reset()
|
||||
calculator.compute_assiduites(abs_just)
|
||||
nb_abs_just: dict = calculator.to_dict()[metrique]
|
||||
calcul : dict = calculator.to_dict(only_total=False)
|
||||
nb_abs: dict = calcul["absent"][metrique]
|
||||
nb_abs_just: dict = calcul["absent_just"][metrique]
|
||||
|
||||
r = (nb_abs, nb_abs_just)
|
||||
if moduleimpl_id is None:
|
||||
|
@ -473,6 +473,10 @@ def _record_assiduite_etud(
|
||||
)
|
||||
db.session.add(ass)
|
||||
db.session.commit()
|
||||
|
||||
# Invalider cache
|
||||
scass.simple_invalidate_cache(ass.to_dict(), etud.id)
|
||||
|
||||
return True
|
||||
except ScoValueError as exc:
|
||||
form.set_error(f"Erreur: {exc.args[0]}")
|
||||
|
@ -405,6 +405,8 @@ def _get_justi(
|
||||
|
||||
def essais_cache(etudid, sems: tuple[FormSemestre], moduleimpls: list[ModuleImpl]):
|
||||
"""Vérification des fonctionnalités du cache"""
|
||||
# TODO faire un test séparé du test_general
|
||||
# voir test_calcul_assiduites pour faire
|
||||
|
||||
date_deb: str = "2022-09-01T07:00"
|
||||
date_fin: str = "2023-01-31T19:00"
|
||||
|
Loading…
Reference in New Issue
Block a user