Skip to content

Commit

Permalink
boxine#91 display progression for on-going parent_tasks
Browse files Browse the repository at this point in the history
cf boxine#91:
displaying progression for parent_tasks if execution is on-going
(format: f'{obj.progress_count}/{obj.total}')
or last_signal
  • Loading branch information
Skrattoune authored Mar 24, 2022
1 parent db534b9 commit 2067695
Showing 1 changed file with 16 additions and 1 deletion.
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

0 comments on commit 2067695

Please sign in to comment.