From 905ee51e6d0800810ad4a54d8d08585e5db52353 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Wed, 7 Nov 2018 20:12:36 +0100 Subject: [PATCH] First working version of the app maintainer dashboard --- app/app.py | 22 +++- app/models/applists.py | 17 ++-- app/templates/base.html | 3 + app/templates/maintainer.html | 187 ++++++++++++++++++++++++++++++++++ 4 files changed, 222 insertions(+), 7 deletions(-) create mode 100644 app/templates/maintainer.html diff --git a/app/app.py b/app/app.py index 70f4b9a..491deb5 100644 --- a/app/app.py +++ b/app/app.py @@ -1,6 +1,7 @@ from flask import render_template, make_response, Blueprint from .models.pr import PullRequest -from .models.appci import App, AppCI, AppCIBranch +from .models.applists import App +from .models.appci import AppCI, AppCIBranch from .models.unlistedapps import UnlistedApp from .settings import SITE_ROOT import json @@ -118,6 +119,9 @@ def badge(app): badge = "level%s.svg" % level if not level is None else "unknown.svg" + if not app.ci_enabled: + badge = "unknown.svg" + svg = open("./app/static/badges/%s" % badge).read() response = make_response(svg) response.content_type = 'image/svg+xml' @@ -151,3 +155,19 @@ def appsobservatory_unlisted(): return render_template("unlistedapps.html", apps=apps) +@main.route('/app_maintainer_dash') +def app_maintainer_dash(): + + maintainers = set() + apps = App.query.all() + for app in apps: + maintainers.update(app.maintainers) + for test in app.most_recent_tests_per_branch(): + if test.branch.name == "stable": + app.ci_level = test.level + + maintainers = sorted(maintainers, key=lambda m: m.lower()) + apps = sorted(apps, key=lambda app: app.name.lower()) + + return render_template("maintainer.html", maintainers=maintainers, apps=apps) + diff --git a/app/models/applists.py b/app/models/applists.py index 8d587ba..38d45e9 100644 --- a/app/models/applists.py +++ b/app/models/applists.py @@ -70,6 +70,7 @@ class AppList(db.Model): known_app.maintainers = [ maintainer["name"] for maintainer in maintainers_info ] known_app.maintained = app.get("maintained", True) + known_app.state = app["state"] known_app.ci_enabled = app["state"] == self.state_for_ci known_app.public_level = app.get("level", None) @@ -78,20 +79,18 @@ class AppList(db.Model): known_app.public_commit = app["git"]["revision"] known_app.master_commit = g.commit(known_app, "master") + known_app.public_commit_date = g.commit_date(known_app, known_app.public_commit) + known_app.master_commit_date = g.commit_date(known_app, known_app.master_commit) known_app.testing_diff = g.diff(known_app, "master", "testing")["ahead_by"] known_app.opened_issues = issues_and_prs["nb_issues"] known_app.opened_prs = issues_and_prs["nb_prs"] - known_app.public_vs_master_time_diff = \ - (g.commit_date(known_app, known_app.master_commit) - - g.commit_date(known_app, known_app.public_commit)).days else: known_app.public_commit = "???" known_app.master_commit = "???" known_app.testing_diff = -1 known_app.opened_issues = 0 known_app.opened_prs = 0 - known_app.public_vs_master_time_diff = 0 try: db.session.commit() @@ -106,6 +105,7 @@ class App(db.Model): repo = db.Column(db.String(128), unique=True, nullable=False) maintainers = db.Column(db.PickleType) maintained = db.Column(db.Boolean, nullable=False) + state = db.Column(db.String(64), nullable=False) ci_enabled = db.Column(db.Boolean, nullable=False) public_level = db.Column(db.Integer, default=-1, nullable=True) @@ -115,10 +115,11 @@ class App(db.Model): # 'Status info' stuff public_commit = db.Column(db.String(64), nullable=False) master_commit = db.Column(db.String(64), nullable=False) + public_commit_date = db.Column(db.DateTime, nullable=True) + master_commit_date = db.Column(db.DateTime, nullable=True) testing_diff = db.Column(db.Integer, default=-1) opened_issues = db.Column(db.Integer, default=-1) opened_prs = db.Column(db.Integer, default=-1) - public_vs_master_time_diff = db.Column(db.Integer, default=9999) def __repr__(self): return '' % self.name @@ -126,9 +127,13 @@ class App(db.Model): def init(): pass + @property + def public_vs_master_time_diff(self): + return (self.public_commit_date - self.master_commit_date).days + def most_recent_tests_per_branch(self): - from appci import AppCIBranch, AppCIResult, AppCI + from app.models.appci import AppCIBranch, AppCIResult, AppCI branches = AppCIBranch.query.all() for branch in branches: most_recent_test = AppCIResult.query \ diff --git a/app/templates/base.html b/app/templates/base.html index 3b9d87e..bc4a347 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -50,6 +50,9 @@ Unlisted apps + diff --git a/app/templates/maintainer.html b/app/templates/maintainer.html new file mode 100644 index 0000000..f2871b3 --- /dev/null +++ b/app/templates/maintainer.html @@ -0,0 +1,187 @@ +{% extends "base.html" %} +{% block content %} + +
+
+ +
+
+ +
+
+
+ + + + + + + + + + + + + + + + {% for app in apps %} + + + + + + + + + + {% if app.maintained %} + + + + {% if app.state == "inprogress" or app.state == "notworking" %} + + + {% else %} + + + + + + + + {% endif %} + + + + + + + + + + {% else %} + ??? + {% endif %} + + + + + {% endfor %} + +
App
Declared state
Maintained
Public level
CI level
# opened issues
# opened PR
Last commit
+ + + {{ app.name }} + + + {% if app.list.name == "official" %} + + {% elif app.state == "working" %} + + {% elif app.state == "inprogress" %} + + {% else %} + + {% endif %} + + + {% else %} + + + {% endif %} +
+
{{ app.public_level if app.public_level >= 0 else "?" }}
+
+
{{ app.ci_level if app.ci_level and app.ci_level >= 0 else "?" }}
+
{{ app.opened_issues }}{{ app.opened_prs }} + {% if app.public_commit_date %} + + + + +
+
+
+
+ + + +{% endblock %}