1
0
forked from ScoDoc/ScoDoc

Cache table recap: combinaisons evals/jury

This commit is contained in:
Emmanuel Viennet 2023-02-21 01:07:21 +01:00
parent 5177d46815
commit cac6201696
2 changed files with 28 additions and 8 deletions

View File

@ -229,6 +229,26 @@ class TableRecapWithEvalsCache(ScoDocCache):
duration = 12 * 60 * 60 # ttl 12h
class TableJuryCache(ScoDocCache):
"""Cache table recap (pour TableRecap)
Clé: formsemestre_id
Valeur: le html (<div class="table_recap">...</div>)
"""
prefix = "RECAPJURY"
duration = 12 * 60 * 60 # ttl 12h
class TableJuryWithEvalsCache(ScoDocCache):
"""Cache table recap (pour TableRecap)
Clé: formsemestre_id
Valeur: le html (<div class="table_recap">...</div>)
"""
prefix = "RECAPJURYWITHEVALS"
duration = 12 * 60 * 60 # ttl 12h
def invalidate_formsemestre( # was inval_cache(formsemestre_id=None, pdfonly=False)
formsemestre_id=None, pdfonly=False
):

View File

@ -449,11 +449,14 @@ def gen_formsemestre_recapcomplet_html_table(
"""
table = None
table_html = None
cache_class = {
(True, True): sco_cache.TableJuryWithEvalsCache,
(True, False): sco_cache.TableJuryCache,
(False, True): sco_cache.TableRecapWithEvalsCache,
(False, False): sco_cache.TableRecapCache,
}[(bool(mode_jury), bool(include_evaluations))]
if not selected_etudid:
if include_evaluations:
table_html = sco_cache.TableRecapWithEvalsCache.get(formsemestre.id)
else:
table_html = sco_cache.TableRecapCache.get(formsemestre.id)
table_html = cache_class.get(formsemestre.id)
if table_html is None:
table = _gen_formsemestre_recapcomplet_table(
formsemestre,
@ -464,10 +467,7 @@ def gen_formsemestre_recapcomplet_html_table(
selected_etudid=selected_etudid,
)
table_html = table.html()
if include_evaluations:
sco_cache.TableRecapWithEvalsCache.set(formsemestre.id, table_html)
else:
sco_cache.TableRecapCache.set(formsemestre.id, table_html)
cache_class.set(formsemestre.id, table_html)
return table_html, table