summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2015-06-15 17:47:49 +0100
committerSam Thursfield <sam.thursfield@codethink.co.uk>2015-06-15 17:47:49 +0100
commitbc3fff6a7b5cc3df2b2d2c90d3fc82f8c71fc923 (patch)
tree53f136a45f640cabffe40f89a06a9d701f8ac6c0
parent293a78bf80ee8a45df7e8cabe188c0737a8e1c8e (diff)
downloadmorph-cache-server-bc3fff6a7b5cc3df2b2d2c90d3fc82f8c71fc923.tar.gz
frontend: Show builds for each artifact
-rw-r--r--deploy.yaml5
-rw-r--r--morphcacheserver/frontend.py19
2 files changed, 22 insertions, 2 deletions
diff --git a/deploy.yaml b/deploy.yaml
index b453b2c..f31676b 100644
--- a/deploy.yaml
+++ b/deploy.yaml
@@ -9,7 +9,10 @@
- name: cache user
user: name=cache
- # This isn't in Baserock right now, so fetch it from Pip.
+ # These aren't in Baserock right now, so fetch from Pip.
+ - name: arrow date & time library
+ pip: name=arrow
+
- name: yoyo-migrations library
pip: name=yoyo-migrations
diff --git a/morphcacheserver/frontend.py b/morphcacheserver/frontend.py
index b463c33..f55fa92 100644
--- a/morphcacheserver/frontend.py
+++ b/morphcacheserver/frontend.py
@@ -13,6 +13,7 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
+import arrow
from bottle import Bottle, request, static_file, template
import math
@@ -21,6 +22,10 @@ import math
def make_table(data, heading_ids, heading_titles, row_class_cb=None):
'''Render 'data' as a HTML table.'''
+ noop = lambda *args: ''
+
+ row_class_cb = row_class_cb or noop
+
table_template = """
<table>
<tr class="headings">
@@ -95,9 +100,21 @@ def web_frontend(db):
@app.get('/artifacts/<cache_name>')
def artifact_info(cache_name):
source_repo, source_ref = db.view_artifact_info(cache_name)
+
+ builds = sorted(db.iter_builds_for_artifact_file(cache_name))
+
+ for item in builds:
+ arrow_date = arrow.get(item['build_datetime'])
+ item['build_datetime_string'] = arrow_date.humanize()
+
+ builds_table = make_table(
+ builds,
+ ['builder_name', 'build_datetime_string', 'hash_sha1'],
+ ['Builder ID', 'Build date', 'SHA1'])
+
return template('morphcacheserver/templates/artifact_info',
cache_name=cache_name, source_repo=source_repo,
- source_ref=source_ref)
+ source_ref=source_ref, builds_table=builds_table)
@app.get('/')
def frontpage():