8
8
)
9
9
from bolt .admin .cards import Card
10
10
from bolt .admin .dates import DatetimeRangeAliases
11
+ from bolt .db import models
11
12
from bolt .http import HttpResponseRedirect
12
13
from bolt .runtime import settings
13
14
@@ -116,7 +117,7 @@ def get_number(self):
116
117
@register_viewset
117
118
class JobRequestViewset (AdminModelViewset ):
118
119
class ListView (AdminModelListView ):
119
- nav_section = "Jobs "
120
+ nav_section = "Worker "
120
121
model = JobRequest
121
122
fields = ["id" , "job_class" , "priority" , "created_at" ]
122
123
@@ -127,7 +128,7 @@ class DetailView(AdminModelDetailView):
127
128
@register_viewset
128
129
class JobViewset (AdminModelViewset ):
129
130
class ListView (AdminModelListView ):
130
- nav_section = "Jobs "
131
+ nav_section = "Worker "
131
132
model = Job
132
133
fields = ["id" , "job_class" , "priority" , "created_at" , "started_at" ]
133
134
actions = ["Delete" ]
@@ -147,14 +148,16 @@ class DetailView(AdminModelDetailView):
147
148
@register_viewset
148
149
class JobResultViewset (AdminModelViewset ):
149
150
class ListView (AdminModelListView ):
150
- nav_section = "Jobs "
151
+ nav_section = "Worker "
151
152
model = JobResult
152
153
fields = [
153
154
"id" ,
154
155
"job_class" ,
155
156
"priority" ,
156
157
"created_at" ,
157
158
"status" ,
159
+ "retried" ,
160
+ "is_retry" ,
158
161
]
159
162
cards = [
160
163
SuccessfulJobsCard ,
@@ -173,14 +176,26 @@ class ListView(AdminModelListView):
173
176
"Retry" ,
174
177
]
175
178
allow_global_search = False
176
- default_datetime_range = DatetimeRangeAliases .LAST_7_DAYS
179
+ default_datetime_range = DatetimeRangeAliases .LAST_30_DAYS
177
180
178
181
def get_description (self ):
179
182
delta = timedelta (seconds = settings .JOBS_CLEARABLE_AFTER )
180
183
return f"Jobs are cleared after { _td_format (delta )} "
181
184
182
185
def get_initial_queryset (self ):
183
186
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
+ )
184
199
if self .filter == "Successful" :
185
200
return queryset .successful ()
186
201
if self .filter == "Errored" :
0 commit comments