From db534b9fec73f6827e1b7cfb59ef93e57659b0c0 Mon Sep 17 00:00:00 2001 From: Skrattoune <56255427+Skrattoune@users.noreply.github.com> Date: Thu, 24 Mar 2022 15:35:03 +0100 Subject: [PATCH 1/2] Differentiate btw signal_complete & issue_signals Used for displaying parent_task progression (cf #91) --- huey_monitor/constants.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/huey_monitor/constants.py b/huey_monitor/constants.py index a2c9f32..50280ec 100644 --- a/huey_monitor/constants.py +++ b/huey_monitor/constants.py @@ -6,13 +6,16 @@ # It does not mean that execution was successfully completed! # # Collect these Huey signals here: -ENDED_HUEY_SIGNALS = ( +ISSUE_HUEY_SIGNALS = [ _huey_signals.SIGNAL_CANCELED, - _huey_signals.SIGNAL_COMPLETE, _huey_signals.SIGNAL_ERROR, _huey_signals.SIGNAL_EXPIRED, _huey_signals.SIGNAL_REVOKED, _huey_signals.SIGNAL_INTERRUPTED, -) +] + +ENDED_HUEY_SIGNALS = ISSUE_HUEY_SIGNALS + [ + _huey_signals.SIGNAL_COMPLETE, +] TASK_MODEL_DESC_MAX_LENGTH = 128 From 2067695192708063078541d429ba04435fce1707 Mon Sep 17 00:00:00 2001 From: Skrattoune <56255427+Skrattoune@users.noreply.github.com> Date: Thu, 24 Mar 2022 15:44:31 +0100 Subject: [PATCH 2/2] #91 display progression for on-going parent_tasks cf #91: displaying progression for parent_tasks if execution is on-going (format: f'{obj.progress_count}/{obj.total}') or last_signal --- huey_monitor/admin.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/huey_monitor/admin.py b/huey_monitor/admin.py index 14696e6..3315af1 100644 --- a/huey_monitor/admin.py +++ b/huey_monitor/admin.py @@ -6,6 +6,7 @@ from django.utils.translation import gettext_lazy as _ from huey_monitor.models import SignalInfoModel, TaskModel +from huey_monitor.constants import ISSUE_HUEY_SIGNALS class TaskModelChangeList(ChangeList): @@ -59,6 +60,19 @@ def task_hierarchy_info(self, obj): def has_change_permission(self, request, obj=None): return False + def status(self, obj): + """ + displaying progression for parent_tasks if execution is on-going + (format: f'{obj.progress_count}/{obj.total}') + or last_signal + """ + if not obj.state in ISSUE_HUEY_SIGNALS: + if obj.total and obj.progress_count: + if obj.total > obj.progress_count: + return f'{obj.progress_count}/{obj.total}' + + return obj.state + def signals(self, obj): signals = SignalInfoModel.objects.filter(task_id=obj.pk).order_by('-create_dt') context = { @@ -81,7 +95,7 @@ def duration(self, obj): list_display = ( 'human_update_dt', 'column_name', - 'state', + 'status', 'total', 'human_unit', 'human_percentage', @@ -91,6 +105,7 @@ def duration(self, obj): ) readonly_fields = ( 'task_id', 'signals', 'create_dt', 'update_dt', + 'status', 'human_percentage', 'human_progress', 'human_throughput',