mirror of
https://github.com/YunoHost/tartiflette.git
synced 2024-09-03 20:06:08 +02:00
Replace old broken rss feed with an html catalog news page
This commit is contained in:
parent
1e7d2f92a2
commit
a1b172ee09
4 changed files with 52 additions and 8 deletions
11
app/app.py
11
app/app.py
|
@ -149,12 +149,11 @@ def appsobservatory_history():
|
||||||
return render_template('applist_history.html', data=data)
|
return render_template('applist_history.html', data=data)
|
||||||
|
|
||||||
|
|
||||||
@main.route('/appsobservatory/rss')
|
@main.route('/appsobservatory/news')
|
||||||
def appsobservatory_rss():
|
def appsobservatory_news():
|
||||||
file_ = open("./app/scripts/appListsHistory/atom.xml").read()
|
news_per_date = json.loads(open("./app/scripts/appListsHistory/news.json").read())
|
||||||
response = make_response(file_)
|
return render_template('applist_news.html', news_per_date=reversed(news_per_date.items()))
|
||||||
response.headers['Content-Type'] = 'application/rss+xml'
|
|
||||||
return response
|
|
||||||
|
|
||||||
@main.route('/appsobservatory/unlisted')
|
@main.route('/appsobservatory/unlisted')
|
||||||
def appsobservatory_unlisted():
|
def appsobservatory_unlisted():
|
||||||
|
|
|
@ -13,6 +13,7 @@ from app import db, create_app
|
||||||
from app.models.appcatalog import App
|
from app.models.appcatalog import App
|
||||||
app_ = create_app()
|
app_ = create_app()
|
||||||
|
|
||||||
|
|
||||||
def _time_points_until_today():
|
def _time_points_until_today():
|
||||||
|
|
||||||
year = 2017
|
year = 2017
|
||||||
|
@ -129,6 +130,49 @@ def make_count_summary():
|
||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
def make_news():
|
||||||
|
|
||||||
|
news_per_date = {d.strftime("%b %d %Y"): {"broke": [], "repaired": [], "removed": [], "added": []} for d in time_points_until_today}
|
||||||
|
previous_j = {}
|
||||||
|
|
||||||
|
def level(infos):
|
||||||
|
lev = infos.get("level")
|
||||||
|
if lev is None or (isinstance(lev, str) and not lev.isdigit()):
|
||||||
|
return -1
|
||||||
|
else:
|
||||||
|
return int(lev)
|
||||||
|
|
||||||
|
|
||||||
|
for d in time_points_until_today:
|
||||||
|
d_label = d.strftime("%b %d %Y")
|
||||||
|
|
||||||
|
print("Analyzing %s ..." % d.strftime("%y-%m-%d"))
|
||||||
|
|
||||||
|
# Load corresponding json
|
||||||
|
j = json.loads(open("./.work/merged_lists.json.%s" % d.strftime("%y-%m-%d")).read())
|
||||||
|
|
||||||
|
apps_current = set(k for k, infos in j.items() if infos["state"] in ["working", "official"] and level(infos) != -1)
|
||||||
|
apps_current_good = set(k for k, infos in j.items() if k in apps_current and level(infos) > 4)
|
||||||
|
apps_current_broken = set(k for k, infos in j.items() if k in apps_current and level(infos) <= 4)
|
||||||
|
|
||||||
|
apps_previous = set(k for k, infos in previous_j.items() if infos["state"] in ["working", "official"] and level(infos) != -1)
|
||||||
|
apps_previous_good = set(k for k, infos in previous_j.items() if k in apps_previous and level(infos) > 4)
|
||||||
|
apps_previous_broken = set(k for k, infos in previous_j.items() if k in apps_previous and level(infos) <= 4)
|
||||||
|
|
||||||
|
news = news_per_date[d_label]
|
||||||
|
for app in set(apps_previous_good & apps_current_broken):
|
||||||
|
news["broke"].append((app, j[app]["url"]))
|
||||||
|
for app in set(apps_previous_broken & apps_current_good):
|
||||||
|
news["repaired"].append((app, j[app]["url"]))
|
||||||
|
for app in set(apps_current - apps_previous):
|
||||||
|
news["added"].append((app, j[app]["url"]))
|
||||||
|
for app in set(apps_previous - apps_current):
|
||||||
|
news["removed"].append((app, previous_j[app]["url"]))
|
||||||
|
|
||||||
|
previous_j = j
|
||||||
|
|
||||||
|
json.dump(news_per_date, open('news.json', 'w'))
|
||||||
|
|
||||||
|
|
||||||
def update_catalog_stats(app, history):
|
def update_catalog_stats(app, history):
|
||||||
|
|
||||||
|
@ -146,3 +190,4 @@ def update_catalog_stats(app, history):
|
||||||
|
|
||||||
get_lists_history()
|
get_lists_history()
|
||||||
make_count_summary()
|
make_count_summary()
|
||||||
|
make_news()
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||||
<a class="dropdown-item" href="{{ url_for('main.testings')}}">Testing PRs</a>
|
<a class="dropdown-item" href="{{ url_for('main.testings')}}">Testing PRs</a>
|
||||||
<a class="dropdown-item" href="{{ url_for('main.appsobservatory_history')}}">History graphs</a>
|
<a class="dropdown-item" href="{{ url_for('main.appsobservatory_history')}}">History graphs</a>
|
||||||
<a class="dropdown-item" href="{{ url_for('main.appsobservatory_rss')}}">RSS</a>
|
<a class="dropdown-item" href="{{ url_for('main.appsobservatory_news')}}">Catalog news</a>
|
||||||
<a class="dropdown-item" href="{{ url_for('main.appsobservatory_unlisted')}}">Unlisted apps</a>
|
<a class="dropdown-item" href="{{ url_for('main.appsobservatory_unlisted')}}">Unlisted apps</a>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
Flask==1.0.2
|
Flask==1.0.2
|
||||||
Flask-Migrate
|
Flask-Migrate<3.0
|
||||||
Flask-SQLAlchemy
|
Flask-SQLAlchemy
|
||||||
Flask-Script
|
Flask-Script
|
||||||
Jinja2
|
Jinja2
|
||||||
|
|
Loading…
Reference in a new issue