From 86b169bd6c886986a65a28c3c9364d6d081c4cad Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Mon, 14 Jan 2019 12:30:08 +0100 Subject: [PATCH 2/3] visualization: add setting to disable cache (#27407) --- bijoe/settings.py | 2 ++ bijoe/visualization/utils.py | 4 +++- tests/settings.py | 1 + tox.ini | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 tests/settings.py diff --git a/bijoe/settings.py b/bijoe/settings.py index d99f15c..45bb96c 100644 --- a/bijoe/settings.py +++ b/bijoe/settings.py @@ -170,5 +170,7 @@ SELECT2_CSS = xstatic('select2', 'select2.min.css') BIJOE_SCHEMAS = [] +BIJOE_CACHE = True + if 'BIJOE_SETTINGS_FILE' in os.environ: execfile(os.environ['BIJOE_SETTINGS_FILE']) diff --git a/bijoe/visualization/utils.py b/bijoe/visualization/utils.py index 8c1b9f8..f57412c 100644 --- a/bijoe/visualization/utils.py +++ b/bijoe/visualization/utils.py @@ -26,6 +26,7 @@ from django.utils.safestring import mark_safe from django.utils.translation import ugettext_lazy as _ from django.core.cache import cache from django.http import Http404 +from django.conf import settings from ..utils import get_warehouses, human_join from ..engine import Engine @@ -164,7 +165,8 @@ class Visualization(object): data = cache.get(key) if data is None: data = list(self.data()) - cache.set(key, data) + if settings.BIJOE_CACHE: + cache.set(key, data) return data def table(self): diff --git a/tests/settings.py b/tests/settings.py new file mode 100644 index 0000000..5e7ac02 --- /dev/null +++ b/tests/settings.py @@ -0,0 +1 @@ +BIJOE_CACHE = False diff --git a/tox.ini b/tox.ini index 9b24449..f7c2581 100644 --- a/tox.ini +++ b/tox.ini @@ -12,6 +12,7 @@ usedevelop = true basepython = python2 setenv = DJANGO_SETTINGS_MODULE=bijoe.settings + BIJOE_SETTINGS_FILE=tests/settings.py coverage: COVERAGE=--junit-xml=test_results.xml --cov=bijoe --cov-report xml deps = dj18: django>=1.8,<1.9 -- 2.20.1