From 67fc12053ed2519d5cb3c7fa6001b9482ba5a21e Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sun, 13 Feb 2022 23:53:11 +0100 Subject: [PATCH] Elimination des derniers NotesTableCache --- app/comp/res_common.py | 6 ++--- app/models/formsemestre.py | 1 + app/pe/pe_jurype.py | 4 +-- app/scodoc/notes_table.py | 2 +- app/scodoc/sco_abs_views.py | 12 ++++++--- app/scodoc/sco_apogee_csv.py | 26 +++++++++++++----- app/scodoc/sco_bulletins.py | 6 +---- app/scodoc/sco_debouche.py | 11 +++++--- app/scodoc/sco_etape_apogee.py | 4 +-- app/scodoc/sco_evaluations.py | 10 ++++--- app/scodoc/sco_export_results.py | 6 ++++- app/scodoc/sco_formsemestre_exterieurs.py | 6 ++++- app/scodoc/sco_formsemestre_status.py | 7 +++-- app/scodoc/sco_liste_notes.py | 15 ++++++----- app/scodoc/sco_moduleimpl_status.py | 1 - app/scodoc/sco_parcours_dut.py | 9 ------- app/scodoc/sco_poursuite_dut.py | 6 ++++- app/scodoc/sco_pvjury.py | 3 --- app/scodoc/sco_saisie_notes.py | 11 ++++---- app/scodoc/sco_semset.py | 6 ++++- app/scodoc/sco_tag_module.py | 6 ++++- app/views/absences.py | 33 ++++++++++++----------- app/views/notes.py | 20 +++++++++----- tests/unit/test_caches.py | 8 ++++-- tests/unit/test_notes_modules.py | 15 ++++++++--- tests/unit/test_sco_basic.py | 8 ++++-- 26 files changed, 145 insertions(+), 97 deletions(-) diff --git a/app/comp/res_common.py b/app/comp/res_common.py index 09a06e796..948c0e95c 100644 --- a/app/comp/res_common.py +++ b/app/comp/res_common.py @@ -4,7 +4,7 @@ # See LICENSE ############################################################################## -from collections import defaultdict, Counter +from collections import Counter from functools import cached_property import numpy as np import pandas as pd @@ -367,7 +367,7 @@ class NotesTableCompat(ResultatsSemestre): sous forme de dict etud, classée dans l'ordre alphabétique de noms. """ - etuds = self.formsemestre.get_inscrits(include_demdef=True, sorted=True) + etuds = self.formsemestre.get_inscrits(include_demdef=True, order=True) return [e.to_dict_scodoc7() for e in etuds] @cached_property @@ -401,7 +401,7 @@ class NotesTableCompat(ResultatsSemestre): d = modimpl.to_dict() # compat ScoDoc < 9.2: ajoute matières d["mat"] = modimpl.module.matiere.to_dict() - modimpls_dict.append(d) + modimpls_dict.append(d) return modimpls_dict def compute_rangs(self): diff --git a/app/models/formsemestre.py b/app/models/formsemestre.py index c2850c2dc..245142484 100644 --- a/app/models/formsemestre.py +++ b/app/models/formsemestre.py @@ -121,6 +121,7 @@ class FormSemestre(db.Model): d.pop("_sa_instance_state", None) # ScoDoc7 output_formators: (backward compat) d["formsemestre_id"] = self.id + d["titre_num"] = self.titre_num() if self.date_debut: d["date_debut"] = self.date_debut.strftime("%d/%m/%Y") d["date_debut_iso"] = self.date_debut.isoformat() diff --git a/app/pe/pe_jurype.py b/app/pe/pe_jurype.py index d29d040ff..2720ad435 100644 --- a/app/pe/pe_jurype.py +++ b/app/pe/pe_jurype.py @@ -322,12 +322,10 @@ class JuryPE(object): etudiants = [] for sem in semsListe: # pour chacun des semestres de la liste - # nt = self.get_notes_d_un_semestre( sem['formsemestre_id'] ) nt = self.get_cache_notes_d_un_semestre(sem["formsemestre_id"]) - # sco_cache.NotesTableCache.get( sem['formsemestre_id']) etudiantsDuSemestre = ( nt.get_etudids() - ) # nt.identdict.keys() # identification des etudiants du semestre + ) # identification des etudiants du semestre if pe_tools.PE_DEBUG: pe_tools.pe_print( diff --git a/app/scodoc/notes_table.py b/app/scodoc/notes_table.py index 7fc03ce89..b1ac97b85 100644 --- a/app/scodoc/notes_table.py +++ b/app/scodoc/notes_table.py @@ -171,7 +171,7 @@ class NotesTable: def __init__(self, formsemestre_id): # log(f"NotesTable( formsemestre_id={formsemestre_id} )") - # raise NotImplementedError() # XXX + raise NotImplementedError() # XXX if not formsemestre_id: raise ValueError("invalid formsemestre_id (%s)" % formsemestre_id) self.formsemestre_id = formsemestre_id diff --git a/app/scodoc/sco_abs_views.py b/app/scodoc/sco_abs_views.py index 2f108c243..d92ee8559 100644 --- a/app/scodoc/sco_abs_views.py +++ b/app/scodoc/sco_abs_views.py @@ -33,7 +33,9 @@ import datetime from flask import url_for, g, request, abort from app import log -from app.models import Identite +from app.comp import res_sem +from app.comp.res_common import NotesTableCompat +from app.models import Identite, FormSemestre import app.scodoc.sco_utils as scu from app.scodoc import notesdb as ndb from app.scodoc.scolog import logdb @@ -118,7 +120,8 @@ def doSignaleAbsence( if moduleimpl_id and moduleimpl_id != "NULL": mod = sco_moduleimpl.moduleimpl_list(moduleimpl_id=moduleimpl_id)[0] formsemestre_id = mod["formsemestre_id"] - nt = sco_cache.NotesTableCache.get(formsemestre_id) + formsemestre = FormSemestre.query.get_or_404(formsemestre_id) + nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre) ues = nt.get_ues_stat_dict() for ue in ues: modimpls = nt.get_modimpls_dict(ue_id=ue["ue_id"]) @@ -179,11 +182,12 @@ def SignaleAbsenceEtud(): # etudid implied menu_module = "" else: formsemestre_id = etud["cursem"]["formsemestre_id"] + formsemestre = FormSemestre.query.get_or_404(formsemestre_id) + nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre) + ues = nt.get_ues_stat_dict() require_module = sco_preferences.get_preference( "abs_require_module", formsemestre_id ) - nt = sco_cache.NotesTableCache.get(formsemestre_id) - ues = nt.get_ues_stat_dict() if require_module: menu_module = """