Skip to content

Commit 8b4383f

Browse files
committed
Remove unmapped tasks
1 parent a2a0db9 commit 8b4383f

2 files changed

Lines changed: 16 additions & 10 deletions

File tree

tubesync/sync/tasks.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,25 @@
4444
register_huey_signals()
4545

4646

47+
def get_task_map():
48+
TASK_MAP = {
49+
'index_source': Source,
50+
'download_media_image': Media,
51+
'download_media_file': Media,
52+
'download_media_metadata': Media,
53+
'save_all_media_for_source': Source,
54+
'rename_all_media_for_source': Source,
55+
'refresh_formats': Media,
56+
}
57+
return { f"sync.tasks.{k}": v for k,v in TASK_MAP.items() }
58+
4759
def map_task_to_instance(task):
4860
'''
4961
Reverse-maps a scheduled backgrond task to an instance. Requires the task name
5062
to be a known task function and the first argument to be a UUID. This is used
5163
because UUID's are incompatible with background_task's "creator" feature.
5264
'''
53-
TASK_MAP = {
54-
'sync.tasks.index_source': Source,
55-
'sync.tasks.download_media_image': Media,
56-
'sync.tasks.download_media_file': Media,
57-
'sync.tasks.download_media_metadata': Media,
58-
'sync.tasks.save_all_media_for_source': Source,
59-
'sync.tasks.rename_all_media_for_source': Source,
60-
'sync.tasks.refresh_formats': Media,
61-
}
65+
TASK_MAP = get_task_map()
6266
MODEL_URL_MAP = {
6367
Source: 'sync:source',
6468
Media: 'sync:media-item',

tubesync/sync/views/tasks.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from django import forms
2121
from ..forms import ScheduleTaskForm
2222
from ..tasks import (
23-
map_task_to_instance, get_error_message,
23+
get_task_map, map_task_to_instance, get_error_message,
2424
get_running_tasks, check_source_directory_exists,
2525
)
2626

@@ -83,6 +83,8 @@ def get_queryset(self):
8383
if self.filter_source:
8484
params_prefix=f'[["{self.filter_source.pk}"'
8585
qs = qs.filter(task_params__istartswith=params_prefix)
86+
if not settings.DEBUG:
87+
qs = qs.filter(name__in=set(get_task_map().keys()))
8688
return qs.order_by(
8789
'-priority',
8890
'scheduled_at',

0 commit comments

Comments
 (0)