Include last successful build date on runners page
authorTom Powell <tom@powell.io>
Tue, 28 May 2019 04:53:47 +0000 (21:53 -0700)
committerTom Powell <tom@powell.io>
Tue, 28 May 2019 04:53:47 +0000 (21:53 -0700)
ui/app.py
ui/templates/runners.html

index 60b450baabfa07d200c27d155b8eb62d63c9fbb5..ba5ef199d7c9a6e4202575b2219fc963afc360d4 100644 (file)
--- a/ui/app.py
+++ b/ui/app.py
@@ -141,7 +141,17 @@ def web_stats():
 
 @app.route("/runners/")
 def web_runners():
-    runners = models.Runner.get().all()
+    #select * from runner join (select * from build where build_status = "success" order by build_date) as builds on builds.build_runner_id = runner.runner_id group by build_runner_id;
+    subquery = models.Build.query.filter(models.Build.build_status == "success").order_by(models.Build.build_date).subquery()
+    runners = models.Runner.query.outerjoin(
+        subquery, subquery.c.build_runner_id == models.Runner.runner_id
+    ).with_entities(
+        models.Runner.runner_id,
+        models.Runner.runner_name,
+        models.Runner.runner_sponsor,
+        models.Runner.runner_sponsor_url,
+        subquery.c.build_date
+    ).group_by(models.Runner.runner_id).all()
     return render_template('runners.html', runners=runners)
 
 @app.route('/api/v1/builds')
index 262d2015de5ab0c23fb9928d997c1843e0f2110b..9a91fc77688669b2866ffb247000b7edb47b857d 100644 (file)
@@ -8,11 +8,13 @@
             <tr>
                 <th scope="col">Name</th>
                 <th scope="col">Sponsor</th>
+                <th scope="col">Last Success</th>
             </tr>
             {% for runner in runners %}
             <tr>
                 <td><a href="/runners/{{runner.runner_name}}">{{runner.runner_name}}</a></td>
                 <td>{% if runner.runner_sponsor_url %}<a href="{{runner.runner_sponsor_url}}">{% endif %}{{runner.runner_sponsor}}{% if runner.runner_sponsor_url %}</a>{% endif %}</td>
+                <td>{{runner.build_date}}</td>
             </tr>
             {% endfor %}
         </table>