mirror of
https://github.com/YunoHost/apps.git
synced 2024-09-03 20:06:07 +02:00
store/dash: add 'last update X hours ago' info at the bottom
This commit is contained in:
parent
a00180833a
commit
9fe7304bac
2 changed files with 10 additions and 1 deletions
10
store/app.py
10
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:
|
||||
|
@ -469,7 +477,7 @@ def dash():
|
|||
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)
|
||||
return render_template("dash.html", data=data, stars=stars, last_data_update=get_dashboard_data.mtime)
|
||||
|
||||
|
||||
@app.route("/charts")
|
||||
|
|
|
@ -202,6 +202,7 @@
|
|||
|
||||
<div id="nbEntriesFound" class="text-center text-gray-600 text-sm py-3"></div>
|
||||
|
||||
<div class="text-center text-gray-600 text-sm py-3">{{ _("Last data update %(time)s ago", time=last_data_update|hours_ago) }}</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue