From a8de00e7b7d82ffccb765678af78cd253324854c Mon Sep 17 00:00:00 2001 From: Skrattoune <56255427+Skrattoune@users.noreply.github.com> Date: Fri, 25 Mar 2022 08:56:58 +0100 Subject: [PATCH 1/2] #91 update parent_task.update_dt on subtask signal cf #91: update update_dt of the parent task when a signal is received from a sub-task --- huey_monitor/tasks.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/huey_monitor/tasks.py b/huey_monitor/tasks.py index 3dea9df..480d881 100644 --- a/huey_monitor/tasks.py +++ b/huey_monitor/tasks.py @@ -7,6 +7,7 @@ import uuid from functools import lru_cache +from django.utils import timezone from django.db import transaction from django.db.models import Sum from huey.contrib.djhuey import on_startup, signal @@ -43,6 +44,10 @@ def update_task_instance(instance, last_signal, task_finished): update_fields.append('progress_count') instance.save(update_fields=update_fields) + + if instance.parent_task: + instance.parent_task.update_dt = timezone.now() + instance.parent_task.save(update_fields='update_dt') @signal() From b1fa8379e117f13659824828a9d5e20eb8aea066 Mon Sep 17 00:00:00 2001 From: Skrattoune <56255427+Skrattoune@users.noreply.github.com> Date: Fri, 9 Feb 2024 12:13:27 +0100 Subject: [PATCH 2/2] remove additional call to timezone.now() --- huey_monitor/tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/huey_monitor/tasks.py b/huey_monitor/tasks.py index 480d881..dd69966 100644 --- a/huey_monitor/tasks.py +++ b/huey_monitor/tasks.py @@ -46,7 +46,7 @@ def update_task_instance(instance, last_signal, task_finished): instance.save(update_fields=update_fields) if instance.parent_task: - instance.parent_task.update_dt = timezone.now() + instance.parent_task.update_dt = last_signal.create_dt instance.parent_task.save(update_fields='update_dt')