Include last built page for all devices in the last 3mo
authorTom Powell <tom@powell.io>
Thu, 6 Jun 2019 01:37:34 +0000 (18:37 -0700)
committerTom Powell <tom@powell.io>
Thu, 6 Jun 2019 01:37:34 +0000 (18:37 -0700)
ui/app.py
ui/templates/builds.html
ui/templates/devices.html [new file with mode: 0644]

index 7ef58894570b04e1743169a13e163be14e029541..b5fd02d433f9c60173bc76f5daf757a93ddd0497 100644 (file)
--- a/ui/app.py
+++ b/ui/app.py
@@ -26,7 +26,8 @@ nav.register_element('top', Navbar(
     "LineageOS Builds",
     View('Builds', '.web_index'),
     View('Runners', '.web_runners'),
-    View('Stats', '.web_stats')
+    View('Devices', '.web_devices'),
+    View('Stats', '.web_stats'),
 ))
 
 headers = {'Private-Token': os.environ.get('GITLAB_TOKEN', '')}
@@ -154,6 +155,11 @@ def web_runners():
     ).group_by(models.Runner.runner_id).order_by(subquery.c.build_date.desc(), models.Runner.runner_name).all()
     return render_template('runners.html', runners=runners)
 
+@app.route("/devices/")
+def web_devices():
+    builds = models.Build.query.filter(models.Build.build_date > datetime.date.today() - datetime.timedelta(90)).group_by(models.Build.build_device).having(func.max(models.Build.build_date)).order_by(func.lower(models.Build.build_device)).all()
+    return render_template("devices.html", builds=builds)
+
 @app.route('/api/v1/builds')
 def api_builds():
     try:
index e368cdb9ad6483b3ad68e362843b0cd50d0b2062..2fd8a4ce159c042bb6283d0fd30fd6a4697cc9d2 100644 (file)
                 <th scope="col">Runner</th>
             </tr>
             {% for build in builds.items %}
-            <tr>
+                {% if build.build_status == "success" %}
+                    {% set color = "default" %}
+                {% elif build.build_status == "pending" %}
+                    {% set color = "info" %}
+                {% elif build.build_status == "failed" %}
+                    {% set color = "danger" %}
+                {% else %}
+                    {% set color = "warning" %}
+                {% endif %}
+            <tr class="{{color}}">
                 <th scope="row"><a href="https://gitlab.com/LineageOS/builder/android/pipelines/{{build.build_id}}">{{build.build_id}}</a></th>
                 <td>{{build.build_status}}</td>
                 <td>{{build.build_device}}</td>
diff --git a/ui/templates/devices.html b/ui/templates/devices.html
new file mode 100644 (file)
index 0000000..27703d8
--- /dev/null
@@ -0,0 +1,42 @@
+{%- extends "base.html" %}
+
+
+{% import "bootstrap/utils.html" as utils %}
+{% block content %}
+    <div class="container">
+        <table class="table table-striped">
+            <tr>
+                <th scope="col">ID</th>
+                <th scope="col">Status</th>
+                <th scope="col">Device</th>
+                <th scope="col">Version</th>
+                <th scope="col">Type</th>
+                <th scope="col">Date</th>
+                <th scope="col">Duration</th>
+                <th scope="col">Runner</th>
+            </tr>
+            {% for build in builds %}
+                {% if build.build_status == "success" %}
+                    {% set color = "default" %}
+                {% elif build.build_status == "pending" %}
+                    {% set color = "info" %}
+                {% elif build.build_status == "failed" %}
+                    {% set color = "danger" %}
+                {% else %}
+                    {% set color = "warning" %}
+                {% endif %}
+            <tr class="{{color}}">
+                <th scope="row"><a href="https://gitlab.com/LineageOS/builder/android/pipelines/{{build.build_id}}">{{build.build_id}}</a></th>
+                <td>{{build.build_status}}</td>
+                <td>{{build.build_device}}</td>
+                <td>{{build.build_version}}</td>
+                <td>{{build.build_type}}</td>
+                <td>{{build.build_date}}</td>
+                <td>{% if build.build_duration %}{{(build.build_duration / 60) | round(2)}} min{% endif %}</td>
+                <td><a href="/runners/{{build.build_runner.runner_name}}">{{build.build_runner.runner_name}}</a></td>
+            </tr>
+            {% endfor %}
+        </table>
+    </div>
+{% include "footer.html" %}
+{% endblock %}