From 4013d60a00d4760e9f13e3d7d37d188152ab504d Mon Sep 17 00:00:00 2001 From: tcely Date: Sat, 5 Jul 2025 03:40:24 -0400 Subject: [PATCH] Adjust the running tasks query set The 12 hour limit may not be needed, but my task history rows are odd from testing at the moment. --- tubesync/sync/views.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tubesync/sync/views.py b/tubesync/sync/views.py index eb31a966..abb4c690 100644 --- a/tubesync/sync/views.py +++ b/tubesync/sync/views.py @@ -867,9 +867,12 @@ class TasksView(ListView): data = super().get_context_data(*args, **kwargs) now_dt = timezone.now() scheduled_qs = get_waiting_tasks() - running_qs = scheduled_qs.filter( - start_at__isnull=False, - end_at__lte=F('start_at'), + # Huey removes running tasks, + # so the waiting tasks will not include them. + running_qs = TaskHistory.objects.filter( + start_at=F('end_at'), + scheduled_at__lte=F('end_at'), + end_at__gte=now_dt-timezone.timedelta(hours=12), ) errors_qs = scheduled_qs.filter( attempts__gt=0