Enable caching
authorTom Powell <tom@powell.io>
Sun, 4 Nov 2018 02:39:47 +0000 (19:39 -0700)
committerTom Powell <tom@powell.io>
Sun, 4 Nov 2018 02:39:47 +0000 (19:39 -0700)
.gitlab-ci.yml
ui/app.py
ui/config.py

index 8c6a9a1be864db8d7c1d31370383988a22306cef..4a0c93a864a7d4ed50b26502485c1be9e9536e56 100644 (file)
@@ -7,6 +7,8 @@ test:
   image: python:3.6
   tags:
     - docker
+  variables:
+    FLASK_TESTING: True
   script:
     - pip install -e .
     - python test.py
index 3a197faff496f9b0cc3397f28fc9410fc3562ab9..b7fdef5bc3bde43d271027dcb17b5b6affbef2ce 100644 (file)
--- 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(
index d01f6f615627a5890cae3b87b55ff77944c36af4..e1191e4c58fed3fc5116a2a2e599475fb77c8ebf 100644 (file)
@@ -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")