abuse background_task queue field to store the source uuid for later easy filtering
This commit is contained in:
parent
647f7162cc
commit
d958f426d7
|
@ -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)
|
||||
)
|
||||
|
||||
|
|
|
@ -13,18 +13,24 @@
|
|||
<div class="col s12">
|
||||
<div class="collection">
|
||||
{% for task in tasks %}
|
||||
<span class="collection-item">
|
||||
|
||||
{% if task.has_error %}
|
||||
<span class="collection-item">
|
||||
<i class="fas fa-exclamation-triangle"></i> <strong>{{ task.verbose_name }}</strong><br>
|
||||
Source: "{{ task.queue }}"<br>
|
||||
Error: "{{ task.error_message }}"<br>
|
||||
<i class="far fa-clock"></i> Task started at <strong>{{ task.run_at|date:'Y-m-d H:i:s' }}</strong>
|
||||
<i class="far fa-clock"></i> Task ran at <strong>{{ task.run_at|date:'Y-m-d H:i:s' }}</strong>
|
||||
</span>
|
||||
{% else %}
|
||||
<span class="collection-item">
|
||||
<i class="fas fa-check"></i> <strong>{{ task.verbose_name }}</strong><br>
|
||||
<i class="far fa-clock"></i> Task started at <strong>{{ task.run_at|date:'Y-m-d H:i:s' }}</strong>
|
||||
Source: "{{ task.queue }}"<br>
|
||||
<i class="far fa-clock"></i> Task ran at <strong>{{ task.run_at|date:'Y-m-d H:i:s' }}</strong>
|
||||
</span>
|
||||
{% endif %}
|
||||
</span>
|
||||
{% empty %}
|
||||
<span class="collection-item no-items"><i class="fas fa-info-circle"></i> There have been no completed tasks.</span>
|
||||
<span class="collection-item no-items"><i class="fas fa-info-circle"></i> There have been no completed tasks{% if source %} that match the specified source filter{% endif %}.</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -64,9 +64,9 @@
|
|||
<div class="collection">
|
||||
{% for task in scheduled %}
|
||||
<a href="{% url task.url pk=task.instance.pk %}" class="collection-item">
|
||||
<i class="far fa-stopwatch"></i> <strong>{{ task }}</strong><br>
|
||||
Scheduled to run {{ task.instance.get_index_schedule_display|lower }}.<br>
|
||||
<i class="fas fa-redo"></i> Task will run at <strong>{{ task.run_at|date:'Y-m-d H:i:s' }}</strong>
|
||||
<i class="fas fa-stopwatch"></i> <strong>{{ task }}</strong><br>
|
||||
{% if task.instance.index_schedule %}Scheduled to run {{ task.instance.get_index_schedule_display|lower }}.<br>{% endif %}
|
||||
<i class="fas fa-redo"></i> Task will next run at <strong>{{ task.run_at|date:'Y-m-d H:i:s' }}</strong>
|
||||
</a>
|
||||
{% empty %}
|
||||
<span class="collection-item no-items"><i class="fas fa-info-circle"></i> There are no scheduled tasks.</span>
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue