From 2e512bc9dffca5624342aa75ca01b3ff7f390141 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 5 Apr 2017 11:33:54 +0200 Subject: Warehouse sheet: provide statistics (refs #3398) - Number of finds (total and by places) - Number of container (total and by places) --- ishtar_common/models.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'ishtar_common/models.py') diff --git a/ishtar_common/models.py b/ishtar_common/models.py index bf5c6056a..1632cbfb2 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -1306,6 +1306,19 @@ class UserDashboard: class DashboardFormItem(object): + """ + Provide methods to manage statistics + """ + + def _get_or_set_stats(self, funcname, update, + timeout=settings.CACHE_TIMEOUT): + key, val = get_cache(self.__class__, [funcname, self.pk]) + if not update and val is not None: + return val + val = getattr(self, funcname)() + cache.set(key, val, timeout) + return val + @classmethod def get_periods(cls, slice='month', fltr={}, date_source='creation'): date_var = date_source + '_date' -- cgit v1.2.3