Fix / finish implementing the new 'long term good quality / broken' flags

This commit is contained in:
root 2020-11-07 19:59:34 +00:00
parent 840e780d56
commit 2ef7a71a5c
3 changed files with 26 additions and 12 deletions

View file

@ -127,8 +127,8 @@ class App(db.Model):
opened_issues = db.Column(db.Integer, default=-1) opened_issues = db.Column(db.Integer, default=-1)
opened_prs = db.Column(db.Integer, default=-1) opened_prs = db.Column(db.Integer, default=-1)
long_term_good_quality = db.Column(db.Boolean, nullable=False) long_term_good_quality = db.Column(db.Boolean)
long_term_broken = db.Column(db.Boolean, nullable=False) long_term_broken = db.Column(db.Boolean)
def __repr__(self): def __repr__(self):
return '<App %r>' % self.name return '<App %r>' % self.name

View file

@ -9,9 +9,9 @@ currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentfram
appdir = os.path.abspath(currentdir + "../../../../") appdir = os.path.abspath(currentdir + "../../../../")
sys.path.insert(0, appdir) sys.path.insert(0, appdir)
from app import db from app import db, create_app
from app.models.applists import App from app.models.applists import App
app_ = create_app()
def _time_points_until_today(): def _time_points_until_today():
@ -104,13 +104,13 @@ def make_count_summary():
infos = j.get(app, {}) infos = j.get(app, {})
if not infos or infos.get("state") not in ["working", "official"]: if not infos or infos.get("state") not in ["working", "official"]:
level = 0 level = -1
else: else:
level = infos.get("level", 0) level = infos.get("level", -1)
try: try:
level = int(level) level = int(level)
except: except:
level = 0 level = -1
history_per_app[app].append({ history_per_app[app].append({
"date": d_label, "date": d_label,
@ -122,16 +122,24 @@ def make_count_summary():
os.system("mkdir -p per_app/") os.system("mkdir -p per_app/")
for app in relevant_apps_to_track: for app in relevant_apps_to_track:
json.dump(history_per_app[app], open('per_app/history_%s.json' % app, 'w')) json.dump(history_per_app[app], open('per_app/history_%s.json' % app, 'w'))
update_catalog_stats(app, history)
with app_.app_context():
for app in relevant_apps_to_track:
update_catalog_stats(app, history_per_app[app])
db.session.commit() db.session.commit()
def update_catalog_stats(app, history): def update_catalog_stats(app, history):
print(app)
try:
app_in_db = App.query.filter_by(name=app).first_or_404() app_in_db = App.query.filter_by(name=app).first_or_404()
app_in_db.long_term_good_quality = len([d for d in history[-50:] if d["level"] > 5]) > 25 except:
app_in_db.long_term_broken = len([d for d in history[-50:] if d["level"] <= 0]) > 25 return
app_in_db.long_term_good_quality = len([d for d in history[-24:] if d["level"] > 5]) > 12
app_in_db.long_term_broken = history[-1]["level"] == 0 and len([d for d in history[-24:] if d["level"] == 0]) > 12
db.session.add(app_in_db) db.session.add(app_in_db)

View file

@ -61,6 +61,12 @@
{% for result in app_results %} {% for result in app_results %}
<tr app="{{ result.app.name }}" class="resultline" level="{{ result.level if result.level >= 0 else "?" }}" {% if result.outdated %}style="opacity: 0.8; background-color: #ddd;"{% endif %} > <tr app="{{ result.app.name }}" class="resultline" level="{{ result.level if result.level >= 0 else "?" }}" {% if result.outdated %}style="opacity: 0.8; background-color: #ddd;"{% endif %} >
<td class="ci-app-row-title"> <td class="ci-app-row-title">
{% if result.app.long_term_good_quality %}
<span class="oi oi-star" title="Long-term good quality" aria-hidden="true" style="color: goldenrod;"></span>
{% endif %}
{% if result.app.long_term_broken %}
<span class="oi oi-flag" title="Long-term broken" aria-hidden="true" style="color: firebrick;"></span>
{% endif %}
<a href="{{ url_for('main.appci_app', app=result.app.name) }}"> <a href="{{ url_for('main.appci_app', app=result.app.name) }}">
<span class="font-weight-bold" title="More tests / info for this app"> <span class="font-weight-bold" title="More tests / info for this app">
{{ result.app.name }}</span> {{ result.app.name }}</span>