Skip to content

Commit ee46d10

Browse files
committed
Show retry info on jobs admin
1 parent 40ed698 commit ee46d10

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

bolt-worker/bolt/worker/admin.py

+19-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
)
99
from bolt.admin.cards import Card
1010
from bolt.admin.dates import DatetimeRangeAliases
11+
from bolt.db import models
1112
from bolt.http import HttpResponseRedirect
1213
from bolt.runtime import settings
1314

@@ -116,7 +117,7 @@ def get_number(self):
116117
@register_viewset
117118
class JobRequestViewset(AdminModelViewset):
118119
class ListView(AdminModelListView):
119-
nav_section = "Jobs"
120+
nav_section = "Worker"
120121
model = JobRequest
121122
fields = ["id", "job_class", "priority", "created_at"]
122123

@@ -127,7 +128,7 @@ class DetailView(AdminModelDetailView):
127128
@register_viewset
128129
class JobViewset(AdminModelViewset):
129130
class ListView(AdminModelListView):
130-
nav_section = "Jobs"
131+
nav_section = "Worker"
131132
model = Job
132133
fields = ["id", "job_class", "priority", "created_at", "started_at"]
133134
actions = ["Delete"]
@@ -147,14 +148,16 @@ class DetailView(AdminModelDetailView):
147148
@register_viewset
148149
class JobResultViewset(AdminModelViewset):
149150
class ListView(AdminModelListView):
150-
nav_section = "Jobs"
151+
nav_section = "Worker"
151152
model = JobResult
152153
fields = [
153154
"id",
154155
"job_class",
155156
"priority",
156157
"created_at",
157158
"status",
159+
"retried",
160+
"is_retry",
158161
]
159162
cards = [
160163
SuccessfulJobsCard,
@@ -173,14 +176,26 @@ class ListView(AdminModelListView):
173176
"Retry",
174177
]
175178
allow_global_search = False
176-
default_datetime_range = DatetimeRangeAliases.LAST_7_DAYS
179+
default_datetime_range = DatetimeRangeAliases.LAST_30_DAYS
177180

178181
def get_description(self):
179182
delta = timedelta(seconds=settings.JOBS_CLEARABLE_AFTER)
180183
return f"Jobs are cleared after {_td_format(delta)}"
181184

182185
def get_initial_queryset(self):
183186
queryset = super().get_initial_queryset()
187+
queryset = queryset.annotate(
188+
retried=models.Case(
189+
models.When(retry_job_request_uuid__isnull=False, then=True),
190+
default=False,
191+
output_field=models.BooleanField(),
192+
),
193+
is_retry=models.Case(
194+
models.When(retry_attempt__gt=0, then=True),
195+
default=False,
196+
output_field=models.BooleanField(),
197+
),
198+
)
184199
if self.filter == "Successful":
185200
return queryset.successful()
186201
if self.filter == "Errored":

0 commit comments

Comments
 (0)