Accélère accès aux préférences

This commit is contained in:
Emmanuel Viennet 2021-11-02 15:49:12 +01:00
parent 7589d4cc34
commit 5002afade1
2 changed files with 6 additions and 18 deletions

View File

@ -46,9 +46,9 @@
# sco_cache.NotesTableCache.delete_many(formsemestre_id_list) # sco_cache.NotesTableCache.delete_many(formsemestre_id_list)
# #
# Bulletins PDF: # Bulletins PDF:
# sco_cache.PDFBulCache.get(formsemestre_id, version) # sco_cache.SemBulletinsPDFCache.get(formsemestre_id, version)
# sco_cache.PDFBulCache.set(formsemestre_id, version, filename, pdfdoc) # sco_cache.SemBulletinsPDFCache.set(formsemestre_id, version, filename, pdfdoc)
# sco_cache.PDFBulCache.delete(formsemestre_id) suppr. toutes les versions # sco_cache.SemBulletinsPDFCache.delete(formsemestre_id) suppr. toutes les versions
# Evaluations: # Evaluations:
# sco_cache.EvaluationCache.get(evaluation_id), set(evaluation_id, value), delete(evaluation_id), # sco_cache.EvaluationCache.get(evaluation_id), set(evaluation_id, value), delete(evaluation_id),

View File

@ -1894,21 +1894,9 @@ class BasePreferences(object):
"""Returns preference value. """Returns preference value.
when no value defined for this semestre, returns global value. when no value defined for this semestre, returns global value.
""" """
params = { if formsemestre_id in self.prefs:
"dept_id": self.dept_id, return self.prefs[formsemestre_id].get(name, self.prefs[None][name])
"name": name, return self.prefs[None][name]
"formsemestre_id": formsemestre_id,
}
cnx = ndb.GetDBConnexion()
plist = self._editor.list(cnx, params)
if not plist:
params["formsemestre_id"] = None
plist = self._editor.list(cnx, params)
if not plist:
return self.default[name]
p = plist[0]
_convert_pref_type(p, self.prefs_dict[name])
return p["value"]
def __contains__(self, item): def __contains__(self, item):
return item in self.prefs[None] return item in self.prefs[None]