Merge pull request #823 from tcely/patch-14

Tweak tasks page
This commit is contained in:
meeb 2025-03-21 02:04:43 +11:00 committed by GitHub
commit 00b88fc87d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 4 deletions

View File

@ -1,4 +1,4 @@
{% extends 'base.html' %}{% load humanize %}
{% extends 'base.html' %}{% load humanize %}{% load filters %}
{% block headtitle %}Tasks{% endblock %}
@ -56,7 +56,9 @@
</div>
<div class="row">
<div class="col s12">
<h2>{{ total_scheduled|intcomma }} Scheduled ({{ scheduled|length|intcomma }} on this page)</h2>
{% with adjusted=total_scheduled|sub:total_errors %}
<h2>{{ adjusted|intcomma }} Scheduled ({{ scheduled|length|intcomma }} on this page)</h2>
{% endwith %}
<p>
Tasks which are scheduled to run in the future or are waiting in a queue to be
processed. They can be waiting for an available worker to run immediately, or

View File

@ -12,3 +12,14 @@ def bytesformat(input):
return output
return output[: -1 ] + 'iB'
@register.filter(is_safe=False)
def sub(value, arg):
"""Subtract the arg from the value."""
try:
return int(value) - int(arg)
except (ValueError, TypeError):
try:
return value - arg
except Exception:
return ""

View File

@ -858,9 +858,9 @@ class TasksView(ListView):
)
sort_keys = (
# key, reverse
('run_now', True),
('priority', 'ASC' != order),
('run_at', False),
('priority', 'ASC' != order),
('run_now', True),
)
data['errors'] = multi_key_sort(data['errors'], sort_keys, attr=True)
data['scheduled'] = multi_key_sort(data['scheduled'], sort_keys, attr=True)