From 9c9c4fbd6e5cd6b42af6719fa46f6fbfa9e9f9b1 Mon Sep 17 00:00:00 2001 From: Arthur Hanson Date: Tue, 24 Sep 2024 06:45:38 -0700 Subject: [PATCH] 17501 fix showing last run of script execution in list view (#17581) * 17501 fix showing last run of script job execution in list view * 17501 fix showing last run of script job execution in list view --- netbox/netbox/models/features.py | 9 ++------- netbox/templates/extras/script_list.html | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/netbox/netbox/models/features.py b/netbox/netbox/models/features.py index 45eb700811..a972277705 100644 --- a/netbox/netbox/models/features.py +++ b/netbox/netbox/models/features.py @@ -408,14 +408,9 @@ class Meta: def get_latest_jobs(self): """ - Return a dictionary mapping of the most recent jobs for this instance. + Return a list of the most recent jobs for this instance. """ - return { - job.name: job - for job in self.jobs.filter( - status__in=JobStatusChoices.TERMINAL_STATE_CHOICES - ).order_by('name', '-created').distinct('name').defer('data') - } + return self.jobs.filter(status__in=JobStatusChoices.TERMINAL_STATE_CHOICES).order_by('-created').defer('data') class JournalingMixin(models.Model): diff --git a/netbox/templates/extras/script_list.html b/netbox/templates/extras/script_list.html index 4699e2c097..5b7361a120 100644 --- a/netbox/templates/extras/script_list.html +++ b/netbox/templates/extras/script_list.html @@ -50,7 +50,7 @@

{% for script in module.scripts.all %} - {% with last_job=script.get_latest_jobs|get_key:script.name %} + {% with last_job=script.get_latest_jobs|first %} {% if script.is_executable %}