From 9893383e476261568b1c67f8bfbbbf20a0e4c084 Mon Sep 17 00:00:00 2001 From: tcely Date: Sun, 9 Mar 2025 17:55:15 -0400 Subject: [PATCH 1/6] Tweak tasks ordering --- tubesync/sync/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tubesync/sync/views.py b/tubesync/sync/views.py index 99844a39..3e1470b2 100644 --- a/tubesync/sync/views.py +++ b/tubesync/sync/views.py @@ -866,9 +866,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) From 6f63714118bd7925e65c530ee882777d0bb772f7 Mon Sep 17 00:00:00 2001 From: tcely Date: Sun, 9 Mar 2025 17:59:18 -0400 Subject: [PATCH 2/6] Remove errors from scheduled Errors are technically scheduled too, but the numbers don't add up for the user and can be confusing when they are included. --- tubesync/sync/templates/sync/tasks.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tubesync/sync/templates/sync/tasks.html b/tubesync/sync/templates/sync/tasks.html index 9aa61d04..b0fcb49e 100644 --- a/tubesync/sync/templates/sync/tasks.html +++ b/tubesync/sync/templates/sync/tasks.html @@ -56,7 +56,7 @@
-

{{ total_scheduled|intcomma }} Scheduled ({{ scheduled|length|intcomma }} on this page)

+

{{ (total_scheduled -total_errors)|intcomma }} Scheduled ({{ scheduled|length|intcomma }} on this page)

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 From 11e815e633123b2c465f08ca33428366e1cfb88d Mon Sep 17 00:00:00 2001 From: tcely Date: Sun, 9 Mar 2025 18:17:02 -0400 Subject: [PATCH 3/6] Use with tag --- tubesync/sync/templates/sync/tasks.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tubesync/sync/templates/sync/tasks.html b/tubesync/sync/templates/sync/tasks.html index b0fcb49e..34a77229 100644 --- a/tubesync/sync/templates/sync/tasks.html +++ b/tubesync/sync/templates/sync/tasks.html @@ -56,7 +56,9 @@

-

{{ (total_scheduled -total_errors)|intcomma }} Scheduled ({{ scheduled|length|intcomma }} on this page)

+ {% with adjusted=(total_scheduled - total_errors) %} +

{{ adjusted|intcomma }} Scheduled ({{ scheduled|length|intcomma }} on this page)

+ {% endwith %}

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 From 29c2d4470476052e60869c8dc0296e0687b8323f Mon Sep 17 00:00:00 2001 From: tcely Date: Sun, 9 Mar 2025 19:27:34 -0400 Subject: [PATCH 4/6] Use a filter --- tubesync/sync/templates/sync/tasks.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tubesync/sync/templates/sync/tasks.html b/tubesync/sync/templates/sync/tasks.html index 34a77229..1202bf70 100644 --- a/tubesync/sync/templates/sync/tasks.html +++ b/tubesync/sync/templates/sync/tasks.html @@ -1,4 +1,4 @@ -{% extends 'base.html' %}{% load humanize %} +{% extends 'base.html' %}{% load humanize %}{% load filters %} {% block headtitle %}Tasks{% endblock %} @@ -56,7 +56,7 @@

- {% with adjusted=(total_scheduled - total_errors) %} + {% with adjusted=total_scheduled|sub:total_errors ) %}

{{ adjusted|intcomma }} Scheduled ({{ scheduled|length|intcomma }} on this page)

{% endwith %}

From e284f760afbd208ae2ff076df8cc23de2820e58a Mon Sep 17 00:00:00 2001 From: tcely Date: Sun, 9 Mar 2025 19:33:45 -0400 Subject: [PATCH 5/6] Add `sub` filter This is the opposite of the default `add` filter. --- tubesync/sync/templatetags/filters.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tubesync/sync/templatetags/filters.py b/tubesync/sync/templatetags/filters.py index 6762f4c4..444969e9 100644 --- a/tubesync/sync/templatetags/filters.py +++ b/tubesync/sync/templatetags/filters.py @@ -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 "" + From 674a1d1d94ae3f9286f6c0749ba219b836e60e3e Mon Sep 17 00:00:00 2001 From: tcely Date: Sun, 9 Mar 2025 19:37:47 -0400 Subject: [PATCH 6/6] fixup: remove extra ')' --- tubesync/sync/templates/sync/tasks.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tubesync/sync/templates/sync/tasks.html b/tubesync/sync/templates/sync/tasks.html index 1202bf70..2b7a1250 100644 --- a/tubesync/sync/templates/sync/tasks.html +++ b/tubesync/sync/templates/sync/tasks.html @@ -56,7 +56,7 @@

- {% with adjusted=total_scheduled|sub:total_errors ) %} + {% with adjusted=total_scheduled|sub:total_errors %}

{{ adjusted|intcomma }} Scheduled ({{ scheduled|length|intcomma }} on this page)

{% endwith %}