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
This commit is contained in:
Arthur Hanson 2024-09-24 06:45:38 -07:00 committed by GitHub
parent 5043eab61e
commit b21e8277aa
2 changed files with 3 additions and 8 deletions

View File

@ -408,14 +408,9 @@ class JobsMixin(models.Model):
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):

View File

@ -50,7 +50,7 @@
</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 %}