webapp: parse rounded timestamps
[~helmut/crossqa.git] / webapp.py
index cfdf434..9e69a18 100644 (file)
--- a/webapp.py
+++ b/webapp.py
@@ -15,6 +15,7 @@ import werkzeug
 
 app = flask.Flask("crossqa")
 app.config["SQLALCHEMY_DATABASE_URI"] = 'sqlite:///db'
+app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
 db = flask_sqlalchemy.SQLAlchemy(app)
 
 src_template = """<!DOCTYPE html>
@@ -46,9 +47,11 @@ src_template = """<!DOCTYPE html>
   </table>
   <h5>See also</h5>
   <ul>
-   <li>
-    <a href="https://bootstrap.debian.net/cross_all/{{ sourcepackage|e }}.html">bootstrap.debian.net</a>
-   </li>
+   {%- if show_bootstrapdn -%}
+    <li>
+     <a href="https://bootstrap.debian.net/cross_all/{{ sourcepackage|e }}.html">bootstrap.debian.net</a>
+    </li>
+   {%- endif -%}
    <li>
     <a href="https://qa.debian.org/dose/debcheck/cross_unstable_main_amd64/">debcheck</a>
    </li>
@@ -87,7 +90,10 @@ src_template = """<!DOCTYPE html>
 
 @app.template_filter("sqltimestamp")
 def sqltimestamp_filter(s):
-    return datetime.datetime.strptime(s, "%Y-%m-%d %H:%M:%S.%f")
+    try:
+        return datetime.datetime.strptime(s, "%Y-%m-%d %H:%M:%S.%f")
+    except ValueError:
+        return datetime.datetime.strptime(s, "%Y-%m-%d %H:%M:%S")
 
 @app.template_filter("formatts")
 def formatts_filter(ts):
@@ -108,9 +114,6 @@ def formatts_filter(ts):
 def arch_format_filter(context, some_archs):
     if context["architectures"] == some_archs:
         return "any"
-    if len(some_archs) > 3:
-        return jinja2.Markup('<span title="%s">%d architectures</span>' %
-                             (", ".join(sorted(some_archs)), len(some_archs)))
     return ", ".join(sorted(some_archs))
 
 def collect_depstate(conn, source):
@@ -143,6 +146,9 @@ def show_source(source):
             SELECT version, architecture, success, starttime, filename
                 FROM builds WHERE source = :source;""")
         context["builds"] = list(conn.execute(query, source=source))
+        context["show_bootstrapdn"] = \
+                any(reason and not reason.startswith("skew ")
+                    for reason in context["depresult"].keys())
     return flask.render_template_string(src_template, **context)
 
 @app.route("/build/<path:filename>")