Optim: retire années de parcours de ue.to_dict()
This commit is contained in:
parent
f94654eaa1
commit
cef298cfbe
@ -87,6 +87,7 @@ class ResultatsSemestre(ResultatsCache):
|
|||||||
self.autorisations_inscription = None
|
self.autorisations_inscription = None
|
||||||
self.moyennes_matieres = {}
|
self.moyennes_matieres = {}
|
||||||
"""Moyennes de matières, si calculées. { matiere_id : Series, index etudid }"""
|
"""Moyennes de matières, si calculées. { matiere_id : Series, index etudid }"""
|
||||||
|
# self._ues_by_id_cache: dict[int, UniteEns] = {} # per-instance cache
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"<{self.__class__.__name__}(formsemestre='{self.formsemestre}')>"
|
return f"<{self.__class__.__name__}(formsemestre='{self.formsemestre}')>"
|
||||||
@ -341,7 +342,9 @@ class ResultatsSemestre(ResultatsCache):
|
|||||||
"""L'état de l'UE pour cet étudiant.
|
"""L'état de l'UE pour cet étudiant.
|
||||||
Result: dict, ou None si l'UE n'est pas dans ce semestre.
|
Result: dict, ou None si l'UE n'est pas dans ce semestre.
|
||||||
"""
|
"""
|
||||||
ue = UniteEns.query.get(ue_id)
|
ue: UniteEns = UniteEns.query.get(ue_id)
|
||||||
|
ue_dict = ue.to_dict()
|
||||||
|
|
||||||
if ue.type == UE_SPORT:
|
if ue.type == UE_SPORT:
|
||||||
return {
|
return {
|
||||||
"is_capitalized": False,
|
"is_capitalized": False,
|
||||||
@ -351,7 +354,7 @@ class ResultatsSemestre(ResultatsCache):
|
|||||||
"cur_moy_ue": 0.0,
|
"cur_moy_ue": 0.0,
|
||||||
"moy": 0.0,
|
"moy": 0.0,
|
||||||
"event_date": None,
|
"event_date": None,
|
||||||
"ue": ue.to_dict(),
|
"ue": ue_dict,
|
||||||
"formsemestre_id": None,
|
"formsemestre_id": None,
|
||||||
"capitalized_ue_id": None,
|
"capitalized_ue_id": None,
|
||||||
"ects_pot": 0.0,
|
"ects_pot": 0.0,
|
||||||
@ -420,7 +423,7 @@ class ResultatsSemestre(ResultatsCache):
|
|||||||
"cur_moy_ue": cur_moy_ue,
|
"cur_moy_ue": cur_moy_ue,
|
||||||
"moy": moy_ue,
|
"moy": moy_ue,
|
||||||
"event_date": ue_cap["event_date"] if is_capitalized else None,
|
"event_date": ue_cap["event_date"] if is_capitalized else None,
|
||||||
"ue": ue.to_dict(),
|
"ue": ue_dict,
|
||||||
"formsemestre_id": ue_cap["formsemestre_id"] if is_capitalized else None,
|
"formsemestre_id": ue_cap["formsemestre_id"] if is_capitalized else None,
|
||||||
"capitalized_ue_id": ue_cap["ue_id"] if is_capitalized else None,
|
"capitalized_ue_id": ue_cap["ue_id"] if is_capitalized else None,
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ class UniteEns(db.Model):
|
|||||||
"""as a dict, with the same conversions as in ScoDoc7
|
"""as a dict, with the same conversions as in ScoDoc7
|
||||||
(except ECTS: keep None)
|
(except ECTS: keep None)
|
||||||
If convert_objects, convert all attributes to native types
|
If convert_objects, convert all attributes to native types
|
||||||
(suitable jor json encoding).
|
(suitable for json encoding).
|
||||||
"""
|
"""
|
||||||
e = dict(self.__dict__)
|
e = dict(self.__dict__)
|
||||||
e.pop("_sa_instance_state", None)
|
e.pop("_sa_instance_state", None)
|
||||||
@ -115,7 +115,7 @@ class UniteEns(db.Model):
|
|||||||
e["ects"] = e["ects"]
|
e["ects"] = e["ects"]
|
||||||
e["coefficient"] = e["coefficient"] if e["coefficient"] else 0.0
|
e["coefficient"] = e["coefficient"] if e["coefficient"] else 0.0
|
||||||
e["code_apogee"] = e["code_apogee"] or "" # pas de None
|
e["code_apogee"] = e["code_apogee"] or "" # pas de None
|
||||||
e["parcour"] = self.parcour.to_dict() if self.parcour else None
|
e["parcour"] = self.parcour.to_dict(with_annees=False) if self.parcour else None
|
||||||
if with_module_ue_coefs:
|
if with_module_ue_coefs:
|
||||||
if convert_objects:
|
if convert_objects:
|
||||||
e["module_ue_coefs"] = [
|
e["module_ue_coefs"] = [
|
||||||
|
Loading…
Reference in New Issue
Block a user