Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#91 display progression for on-going parent_tasks #96

Merged
merged 2 commits into from
Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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