diff --git a/app/sync/signals.py b/app/sync/signals.py index 4ee690df..109247a1 100644 --- a/app/sync/signals.py +++ b/app/sync/signals.py @@ -27,6 +27,7 @@ def source_pre_save(sender, instance, **kwargs): index_source_task( str(instance.pk), repeat=instance.index_schedule, + queue=str(instance.pk), verbose_name=verbose_name.format(instance.name) ) @@ -42,6 +43,7 @@ def source_post_save(sender, instance, created, **kwargs): index_source_task( str(instance.pk), repeat=instance.index_schedule, + queue=str(instance.pk), verbose_name=verbose_name.format(instance.name) ) @@ -82,10 +84,11 @@ def media_post_save(sender, instance, created, **kwargs): if thumbnail_url: log.info(f'Scheduling task to download thumbnail for: {instance.name} ' f'from: {thumbnail_url}') - verbose_name = _('Downloading media thumbnail for "{}') + verbose_name = _('Downloading media thumbnail for "{}"') download_media_thumbnail( str(instance.pk), thumbnail_url, + queue=str(instance.source.pk), verbose_name=verbose_name.format(instance.name) ) diff --git a/app/sync/templates/sync/tasks-completed.html b/app/sync/templates/sync/tasks-completed.html index 3a6977b1..b87805be 100644 --- a/app/sync/templates/sync/tasks-completed.html +++ b/app/sync/templates/sync/tasks-completed.html @@ -13,18 +13,24 @@
{% for task in tasks %} - + {% if task.has_error %} + {{ task.verbose_name }}
+ Source: "{{ task.queue }}"
Error: "{{ task.error_message }}"
- Task started at {{ task.run_at|date:'Y-m-d H:i:s' }} + Task ran at {{ task.run_at|date:'Y-m-d H:i:s' }} +
{% else %} + {{ task.verbose_name }}
- Task started at {{ task.run_at|date:'Y-m-d H:i:s' }} + Source: "{{ task.queue }}"
+ Task ran at {{ task.run_at|date:'Y-m-d H:i:s' }} +
{% endif %}
{% empty %} - There have been no completed tasks. + There have been no completed tasks{% if source %} that match the specified source filter{% endif %}. {% endfor %}
diff --git a/app/sync/templates/sync/tasks.html b/app/sync/templates/sync/tasks.html index 5c9a7e97..9ab66cd7 100644 --- a/app/sync/templates/sync/tasks.html +++ b/app/sync/templates/sync/tasks.html @@ -64,9 +64,9 @@
{% for task in scheduled %} - {{ task }}
- Scheduled to run {{ task.instance.get_index_schedule_display|lower }}.
- Task will run at {{ task.run_at|date:'Y-m-d H:i:s' }} + {{ task }}
+ {% if task.instance.index_schedule %}Scheduled to run {{ task.instance.get_index_schedule_display|lower }}.
{% endif %} + Task will next run at {{ task.run_at|date:'Y-m-d H:i:s' }}
{% empty %} There are no scheduled tasks. diff --git a/app/sync/views.py b/app/sync/views.py index e22fdd73..24bb5a00 100644 --- a/app/sync/views.py +++ b/app/sync/views.py @@ -434,12 +434,10 @@ class CompletedTasksView(ListView): def get_queryset(self): if self.filter_source: - return CompletedTask.objects.all().order_by('-run_at') - #tasks = [] - #for task in CompletedTask.objects.all().order_by('-run_at'): - # # ??? - #q = Media.objects.filter(source=self.filter_source) - return CompletedTask.objects.all().order_by('-run_at') + q = CompletedTask.objects.filter(queue=str(self.filter_source.pk)) + else: + q = CompletedTask.objects.all() + return q.order_by('-run_at') def get_context_data(self, *args, **kwargs): data = super().get_context_data(*args, **kwargs)