Skip to content

Commit a29a07e

Browse files
committed
Fixes #12463: Fix the association of completed jobs with reports & scripts in the REST API
1 parent 42c80f6 commit a29a07e

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

docs/release-notes/version-3.5.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
* [#12415](https://github.com/netbox-community/netbox/issues/12415) - Fix `ImportError` exception when running RQ worker
3535
* [#12433](https://github.com/netbox-community/netbox/issues/12433) - Correct the application of URL query parameters for object list dashboard widgets
3636
* [#12436](https://github.com/netbox-community/netbox/issues/12436) - Remove extraneous "add" button from contact assignments list
37+
* [#12463](https://github.com/netbox-community/netbox/issues/12463) - Fix the association of completed jobs with reports & scripts in the REST API
3738
* [#12464](https://github.com/netbox-community/netbox/issues/12464) - Apply credentials for git data source only when connecting via HTTP/S
3839
* [#12476](https://github.com/netbox-community/netbox/issues/12476) - Fix `TypeError` exception when running the `runscript` management command
3940
* [#12483](https://github.com/netbox-community/netbox/issues/12483) - Fix git remote data syncing when with HTTP proxies defined

netbox/extras/api/views.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,10 @@ def list(self, request):
187187
"""
188188
Compile all reports and their related results (if any). Result data is deferred in the list view.
189189
"""
190-
report_content_type = ContentType.objects.get(app_label='extras', model='report')
191190
results = {
192-
r.name: r
193-
for r in Job.objects.filter(
194-
object_type=report_content_type,
191+
job.name: job
192+
for job in Job.objects.filter(
193+
object_type=ContentType.objects.get(app_label='extras', model='reportmodule'),
195194
status__in=JobStatusChoices.TERMINAL_STATE_CHOICES
196195
).order_by('name', '-created').distinct('name').defer('data')
197196
}
@@ -202,7 +201,7 @@ def list(self, request):
202201

203202
# Attach Job objects to each report (if any)
204203
for report in report_list:
205-
report.result = results.get(report.full_name, None)
204+
report.result = results.get(report.name, None)
206205

207206
serializer = serializers.ReportSerializer(report_list, many=True, context={
208207
'request': request,
@@ -290,12 +289,10 @@ def _get_script(self, pk):
290289
return module, script
291290

292291
def list(self, request):
293-
294-
script_content_type = ContentType.objects.get(app_label='extras', model='script')
295292
results = {
296-
r.name: r
297-
for r in Job.objects.filter(
298-
object_type=script_content_type,
293+
job.name: job
294+
for job in Job.objects.filter(
295+
object_type=ContentType.objects.get(app_label='extras', model='scriptmodule'),
299296
status__in=JobStatusChoices.TERMINAL_STATE_CHOICES
300297
).order_by('name', '-created').distinct('name').defer('data')
301298
}
@@ -306,7 +303,7 @@ def list(self, request):
306303

307304
# Attach Job objects to each script (if any)
308305
for script in script_list:
309-
script.result = results.get(script.full_name, None)
306+
script.result = results.get(script.name, None)
310307

311308
serializer = serializers.ScriptSerializer(script_list, many=True, context={'request': request})
312309

0 commit comments

Comments
 (0)