From: Tom Powell Date: Sun, 4 Nov 2018 02:39:47 +0000 (-0700) Subject: Enable caching X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=616663f4f36ed3d9b1feca62a49bd82aeceee902;p=GitLab%2Fstricted-build%2Flineage_builder.git Enable caching --- diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8c6a9a1..4a0c93a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,6 +7,8 @@ test: image: python:3.6 tags: - docker + variables: + FLASK_TESTING: True script: - pip install -e . - python test.py diff --git a/ui/app.py b/ui/app.py index 3a197fa..b7fdef5 100644 --- a/ui/app.py +++ b/ui/app.py @@ -47,6 +47,7 @@ def parse_args(): args['build_date'] = datetime.datetime.strptime(request.args.get('date'), '%Y-%m-%d').date() return args +@cache.memoize() def stats(): runner_build_times = models.Build.query.join(models.Build.build_runner).with_entities( diff --git a/ui/config.py b/ui/config.py index d01f6f6..e1191e4 100644 --- a/ui/config.py +++ b/ui/config.py @@ -3,7 +3,11 @@ import os SQLALCHEMY_DATABASE_URI = os.environ.get("SQLALCHEMY_DATABASE_URI", 'sqlite:////tmp/ui.db') SQLALCHEMY_TRACK_MODIFICATIONS = False SQLALCHEMY_ECHO = 'FLASK_DEBUG' in os.environ -CACHE_TYPE = 'simple' + +TESTING = 'FLASK_TESTING' in os.environ + +CACHE_TYPE = os.environ.get('CACHE_TYPE', 'simple') +CACHE_DEFAULT_TIMEOUT = int(os.environ.get('CACHE_DEFAULT_TIMEOUT', 60)) GITLAB_WEBHOOK_TOKEN = os.environ.get("GITLAB_WEBHOOK_TOKEN", "secret")