Skip to content

Commit

Permalink
Merge pull request #96 from Skrattoune/patch-5
Browse files Browse the repository at this point in the history
#91 display progression for on-going parent_tasks
  • Loading branch information
jedie authored Mar 30, 2022
2 parents a4de679 + 2067695 commit 5b19146
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
17 changes: 16 additions & 1 deletion huey_monitor/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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 = {
Expand All @@ -81,7 +95,7 @@ def duration(self, obj):
list_display = (
'human_update_dt',
'column_name',
'state',
'status',
'total',
'human_unit',
'human_percentage',
Expand All @@ -91,6 +105,7 @@ def duration(self, obj):
)
readonly_fields = (
'task_id', 'signals', 'create_dt', 'update_dt',
'status',
'human_percentage',
'human_progress',
'human_throughput',
Expand Down
9 changes: 6 additions & 3 deletions huey_monitor/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5b19146

Please sign in to comment.