mirror of
https://github.com/YunoHost/tartiflette.git
synced 2024-09-03 20:06:08 +02:00
Fix / finish implementing the new 'long term good quality / broken' flags
This commit is contained in:
parent
840e780d56
commit
2ef7a71a5c
3 changed files with 26 additions and 12 deletions
|
@ -127,8 +127,8 @@ class App(db.Model):
|
|||
opened_issues = 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_broken = db.Column(db.Boolean, nullable=False)
|
||||
long_term_good_quality = db.Column(db.Boolean)
|
||||
long_term_broken = db.Column(db.Boolean)
|
||||
|
||||
def __repr__(self):
|
||||
return '<App %r>' % self.name
|
||||
|
|
|
@ -9,9 +9,9 @@ currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentfram
|
|||
appdir = os.path.abspath(currentdir + "../../../../")
|
||||
sys.path.insert(0, appdir)
|
||||
|
||||
from app import db
|
||||
from app import db, create_app
|
||||
from app.models.applists import App
|
||||
|
||||
app_ = create_app()
|
||||
|
||||
def _time_points_until_today():
|
||||
|
||||
|
@ -104,13 +104,13 @@ def make_count_summary():
|
|||
infos = j.get(app, {})
|
||||
|
||||
if not infos or infos.get("state") not in ["working", "official"]:
|
||||
level = 0
|
||||
level = -1
|
||||
else:
|
||||
level = infos.get("level", 0)
|
||||
level = infos.get("level", -1)
|
||||
try:
|
||||
level = int(level)
|
||||
except:
|
||||
level = 0
|
||||
level = -1
|
||||
|
||||
history_per_app[app].append({
|
||||
"date": d_label,
|
||||
|
@ -122,16 +122,24 @@ def make_count_summary():
|
|||
os.system("mkdir -p per_app/")
|
||||
for app in relevant_apps_to_track:
|
||||
json.dump(history_per_app[app], open('per_app/history_%s.json' % app, 'w'))
|
||||
update_catalog_stats(app, history)
|
||||
|
||||
db.session.commit()
|
||||
with app_.app_context():
|
||||
for app in relevant_apps_to_track:
|
||||
update_catalog_stats(app, history_per_app[app])
|
||||
|
||||
db.session.commit()
|
||||
|
||||
|
||||
def update_catalog_stats(app, history):
|
||||
|
||||
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
|
||||
app_in_db.long_term_broken = len([d for d in history[-50:] if d["level"] <= 0]) > 25
|
||||
print(app)
|
||||
try:
|
||||
app_in_db = App.query.filter_by(name=app).first_or_404()
|
||||
except:
|
||||
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)
|
||||
|
||||
|
|
|
@ -61,6 +61,12 @@
|
|||
{% 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 %} >
|
||||
<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) }}">
|
||||
<span class="font-weight-bold" title="More tests / info for this app">
|
||||
{{ result.app.name }}</span>
|
||||
|
|
Loading…
Reference in a new issue