Skip to content

Commit

Permalink
17501 fix showing last run of script execution in list view (#17581)
Browse files Browse the repository at this point in the history
* 17501 fix showing last run of script job execution in list view

* 17501 fix showing last run of script job execution in list view
  • Loading branch information
arthanson authored Sep 24, 2024
1 parent 896b5b9 commit 9c9c4fb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
9 changes: 2 additions & 7 deletions netbox/netbox/models/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion netbox/templates/extras/script_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ <h2 class="card-header" id="module{{ module.pk }}">
</thead>
<tbody>
{% 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 %}
<tr>
<td>
{% if script.is_executable %}
Expand Down

0 comments on commit 9c9c4fb

Please sign in to comment.