webapp: add an index listing recently failed builds
authorHelmut Grohne <helmut@subdivi.de>
Thu, 9 May 2019 19:54:42 +0000 (21:54 +0200)
committerHelmut Grohne <helmut@subdivi.de>
Thu, 9 May 2019 19:54:42 +0000 (21:54 +0200)
webapp.py

index c6c7d80..52defa3 100644 (file)
--- a/webapp.py
+++ b/webapp.py
@@ -19,6 +19,60 @@ app.config["SQLALCHEMY_DATABASE_URI"] = 'sqlite:///db'
 app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
 db = flask_sqlalchemy.SQLAlchemy(app)
 
+index_template = """<!DOCTYPE html>
+<html>
+ <head>
+  <title>Debian cross build quality assurance</title>
+ </head>
+ <body>
+  <header>
+   <h1>Debian cross build quality assurance</h1>
+  </header>
+  <section>
+   <h3>Recently failed builds</h3>
+   <table>
+    <thead>
+     <tr>
+      <th>source</th>
+      <th>version</th>
+      <th>architecture</th>
+      <th>started</th>
+      <th>result log</th>
+     </tr>
+    </thead>
+    <tbody>
+     {%- for build in builds|sort(attribute='starttime', reverse=true) -%}
+      <tr>
+       <td>
+        <a href="{{ url_for("show_source", source=build.source) }}">
+         {{- build.source|e -}}
+        </a>
+       </td>
+       <td>{{ build.version|e }}</td>
+       <td>{{ build.architecture|e }}</td>
+       <td>
+        {{- build.starttime|sqltimestamp|formatts -}}
+       </td>
+       <td>
+        <a href="{{ url_for("show_log", filename=build.filename[:-3]) }}">log</a>
+        <a href="{{ url_for("show_log", filename=build.filename) }}">xz</a>
+       </td>
+      </tr>
+     {%- endfor -%}
+    </tbody>
+   </table>
+  </section>
+  <footer>
+   <h3>Details about this service</h3>
+   <ul>
+    <li>Maintainer: Helmut Grohne &lt;helmut@subdivi.de&gt;</li>
+    <li>Source: git://git.subdivi.de/~helmut/crossqa.git</li>
+   </ul>
+  </footer>
+ </body>
+</html>
+"""
+
 src_template = """<!DOCTYPE html>
 <html>
  <head>
@@ -225,6 +279,17 @@ def collect_depstate(conn, source):
         depresult.setdefault(reason, set()).add(arch)
     return version, depresult
 
+@app.route("/")
+def show_index():
+    with db.engine.connect() as conn:
+        builds = list(conn.execute("""
+            SELECT source, version, architecture, starttime, filename
+                FROM builds
+                WHERE success = 0
+                ORDER BY starttime
+                DESC LIMIT 10;"""))
+    return flask.render_template_string(index_template, builds=builds)
+
 @app.route("/src/<source>")
 def show_source(source):
     context = dict(sourcepackage=source)