From 32fd827795560b1e01bedebdaeaef5832a5c4b40 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Fri, 24 May 2024 18:44:07 +0200 Subject: [PATCH] Misc dashboard enhancement (#2365) * store/dash: store by popularity by default * store/dash: add 'last update X hours ago' info at the bottom * store/dash: misc responsiveness improvements --- store/app.py | 15 +++++++- store/templates/dash.html | 73 ++++++++++++++++++++------------------- 2 files changed, 52 insertions(+), 36 deletions(-) diff --git a/store/app.py b/store/app.py index a54a418f..ab316959 100644 --- a/store/app.py +++ b/store/app.py @@ -91,6 +91,14 @@ def days_ago(timestamp): return int((time.time() - timestamp) / (60 * 60 * 24)) +@app.template_filter("hours_ago") +def hours_ago(timestamp): + d = datetime.now() - datetime.fromtimestamp(timestamp) + hours = int(divmod(d.total_seconds(), 3600)[0]) + minutes = int(divmod(d.total_seconds(), 60)[1]) + return f"{hours}:{minutes}h" + + @app.template_filter("format_datetime") def format_datetime(value, format="%d %b %Y %I:%M %p"): if value is None: @@ -464,7 +472,12 @@ Description: {description} @app.route("/dash") def dash(): - return render_template("dash.html", data=get_dashboard_data(), stars=get_stars()) + + # Sort by popularity by default + stars = get_stars() + data = dict(sorted(get_dashboard_data().items(), key=lambda app: len(stars.get(app[0], [])), reverse=True)) + + return render_template("dash.html", data=data, stars=stars, last_data_update=get_dashboard_data.mtime) @app.route("/charts") diff --git a/store/templates/dash.html b/store/templates/dash.html index f300b488..84deb66d 100644 --- a/store/templates/dash.html +++ b/store/templates/dash.html @@ -8,12 +8,13 @@

{{ _("App packaging dashboard") }}

-

{{ _("This is where packagers can monitor the status of automatic tests (CI) and ongoing major pull requests accross all apps. If you want to get started with app packaging in YunoHost, please check out the packaging documentation and come say hi to us on the app packaging chatroom!") }}

+

{{ _("This is where packagers can monitor the status of automatic tests (CI) and ongoing major pull requests accross all apps. If you want to get started with app packaging in YunoHost, please check out the packaging documentation and come say hi to us on the app packaging chatroom!") }}

-
-
+ +
+
{{ _("Filter") }}
-
+
{{ _("Sort by") }}
-
-
+
+ - {{ _("Show only apps you starred") }} -
+ + + + + + {{ _("Show only apps you starred") }}
- +
- + @@ -88,13 +88,15 @@ data-main-ci-level="{% if infos["ci_results"]["main"] %}{{ infos["ci_results"]["main"]["level"] }}{% else %}-1{% endif %}" data-main-ci-daysago="{% if infos["ci_results"]["main"] %}{{ infos["ci_results"]["main"]["timestamp"] | days_ago }}{% else %}-9999{% endif %}" data-nextdebian-ci-level="{% if infos["ci_results"]["nextdebian"] %}{{ infos["ci_results"]["nextdebian"]["level"] }}{% else %}-1{% endif %}" - data-last-update-master-daysago="{{ infos["ci_results"]["main"]["timestamp"] | days_ago }}" - data-last-update-testing-daysago="{% if infos["testing"] %}{{ infos["testing"]["timestamp_updated"] | days_ago }}{% endif %}" - data-last-update-autoupdate-daysago="{% if infos["ci-auto-update"] %}{{ infos["ci-auto-update"]["timestamp_updated"] | days_ago }}{% endif %}" + data-last-update-master="{{ infos["ci_results"]["main"]["timestamp"] }}" + data-last-update-testing="{% if infos["testing"] %}{{ infos["testing"]["timestamp_updated"] }}{% else %}-1{% endif %}" + data-last-update-autoupdate="{% if infos["ci-auto-update"] %}{{ infos["ci-auto-update"]["timestamp_updated"] }}{% else %}-1{% endif %}" data-packaging-format="{{ infos["packaging_format"] }}" > - - + - - - - -
{{ _("App") }}{{ _("App") }} {{ _("Catalog") }} {{ _("Main CI") }} {{ _("Bookworm CI") }}{{ app }} + + {{ app }} + {{ infos["public_level"] }} {% if infos["public_level"] == "?" %} @@ -105,7 +107,7 @@ {% endif %} + 30 %}opacity-50{% endif %}" href="https://ci-apps.yunohost.org/ci/apps/{{ app }}/"> {% if infos["public_level"] == infos["ci_results"]["main"]["level"] %} = @@ -123,7 +125,7 @@ {% endif %} + 30) %}opacity-50{% endif %}" href="https://ci-apps-bookworm.yunohost.org/ci/apps/{{ app }}/"> {% if infos["ci_results"]["nextdebian"] %} {% if infos["public_level"] == infos["ci_results"]["nextdebian"]["level"] %} @@ -145,7 +147,7 @@ {% endif %} + {% if "testing" in infos %} @@ -160,7 +162,7 @@ {% endif %} + @@ -175,7 +177,7 @@ {% endif %} + {% if this_app_stars > 0 %} {{ this_app_stars }} @@ -202,6 +204,7 @@
+
{{ _("Last data update %(time)s ago", time=last_data_update|hours_ago) }}