diff --git a/app/app.py b/app/app.py index ff5ca8e..d279475 100644 --- a/app/app.py +++ b/app/app.py @@ -1,7 +1,7 @@ from datetime import datetime from flask import render_template, make_response, Blueprint from .models.pr import PullRequest -from .models.applists import App +from .models.appcatalog import App from .models.appci import AppCI, AppCIBranch from .models.unlistedapps import UnlistedApp from .settings import SITE_ROOT @@ -189,10 +189,9 @@ def app_maintainer_dash(maintainer=None): if isinstance(app.public_level, str): app.public_level = -1 - if app.maintained and app.state in ["working", "official"]: + if app.maintained and app.state == "working": maintainers.update(app.maintainers) - maintainers = sorted(maintainers, key=lambda m: m.lower()) apps = sorted(apps, key=lambda app: app.name.lower()) diff --git a/app/models/applists.py b/app/models/appcatalog.py similarity index 86% rename from app/models/applists.py rename to app/models/appcatalog.py index 3eecd71..c99652d 100644 --- a/app/models/applists.py +++ b/app/models/appcatalog.py @@ -1,5 +1,4 @@ import re -import os import time import json import requests @@ -8,35 +7,13 @@ import datetime from .. import db -class AppList(db.Model): - - id = db.Column(db.Integer, primary_key=True) - name = db.Column(db.String(64), unique=True, nullable=False) - url = db.Column(db.String(128), nullable=False) - state_for_ci = db.Column(db.String(32), nullable=False) - - def __repr__(self): - return '' % self.name - - def init(): - yield AppList(name='official', - url="https://app.yunohost.org/official.json", - state_for_ci='validated') - yield AppList(name='community', - url="https://app.yunohost.org/community.json", - state_for_ci='working') +class AppCatalog(db.Model): def update(): - applists = AppList.query.all() - for applist in applists: - applist.update_list() - - def update_list(self): - g = Github() - raw_apps = json.loads(requests.get(self.url).text) + raw_apps = json.loads(requests.get("https://app.yunohost.org/default/v2/apps.json").text) for name in sorted(raw_apps.keys()): @@ -52,7 +29,6 @@ class AppList(db.Model): print("Adding new app {}".format(name)) known_app = App(name=name, repo=app["url"], - list=self, public_commit=app["git"]["revision"]) db.session.add(known_app) else: @@ -76,7 +52,6 @@ class AppList(db.Model): elif isinstance(known_app.maintained, str): known_app.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) if "github" in known_app.repo: @@ -112,12 +87,8 @@ class App(db.Model): 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) - list = db.relationship(AppList, backref='apps', lazy=True, uselist=False) - list_id = db.Column(db.ForeignKey(AppList.id)) - # 'Status info' stuff public_commit = db.Column(db.String(64), nullable=False) master_commit = db.Column(db.String(64), nullable=False) diff --git a/app/models/appci.py b/app/models/appci.py index 4df9ff3..a2da1ed 100644 --- a/app/models/appci.py +++ b/app/models/appci.py @@ -3,7 +3,7 @@ import requests import datetime from .. import db -from app.models.applists import App +from app.models.appcatalog import App class AppCIBranch(db.Model): @@ -52,7 +52,7 @@ class AppCIBranch(db.Model): def most_recent_tests_per_app(self): - apps = App.query.filter_by(ci_enabled=True).all() + apps = App.query.filter_by(state="working").all() most_recent_tests = AppCIResult.query \ .filter_by(branch = self) \ .order_by(AppCIResult.date.desc()) \ diff --git a/app/scripts/appListsHistory/script.py b/app/scripts/appListsHistory/script.py index 22ae98f..76c639a 100644 --- a/app/scripts/appListsHistory/script.py +++ b/app/scripts/appListsHistory/script.py @@ -10,7 +10,7 @@ appdir = os.path.abspath(currentdir + "../../../../") sys.path.insert(0, appdir) from app import db, create_app -from app.models.applists import App +from app.models.appcatalog import App app_ = create_app() def _time_points_until_today(): diff --git a/app/templates/appci_app.html b/app/templates/appci_app.html index b629bae..ef6b3e6 100644 --- a/app/templates/appci_app.html +++ b/app/templates/appci_app.html @@ -64,26 +64,6 @@
- {% if app.public_commit == 'HEAD' %} -

- - This app points to HEAD in {{ app.list.name }}.json ! -

- {% elif app.public_commit == app.master_commit %} -

- - Master commit is up to date with {{ app.list.name }}.json ! -

- {% else %} - {% if app.public_vs_master_time_diff > 60 %} -

- {% else %} -

- {% endif %} - - Commit is not up to date on {{ app.list.name }}.json ! -

- {% endif %} {% if app.testing_pr %}

diff --git a/manage.py b/manage.py index c573d0e..35ed8f3 100755 --- a/manage.py +++ b/manage.py @@ -21,13 +21,13 @@ class Update(Command): def run(self, args=None): - valid_what = ["applists", "appci", "pr", "appobservatory"] + valid_what = ["catalog", "appci", "pr", "appobservatory"] what = args[0] if args else None assert what in valid_what, "Please specify what to update among %s" % ', '.join(valid_what) - if what == "applists": - from app.models.applists import AppList - AppList.update() + if what == "catalog": + from app.models.appcatalog import AppCatalog + AppCatalog.update() elif what == "appci": from app.models.appci import AppCI AppCI.update() @@ -49,7 +49,7 @@ class Nuke(Command): def run(self): - import app.models.applists + import app.models.appcatalog import app.models.appci import app.models.pr import app.models.unlistedapps