"""
A list of jobs that came before this one
"""
- jobs = self.backend.jobs._get_jobs("""
- WITH RECURSIVE preceeding_jobs AS (
- SELECT
- jobs.*
- FROM
- jobs
- WHERE
- jobs.superseeded_by = %s
-
- UNION ALL
+ jobs = []
- SELECT
- jobs.*
- FROM
- jobs
- INNER JOIN
- preceeding_jobs ON preceeding_jobs.id = jobs.superseeded_by
- )
+ for job in self.build.alljobs:
+ if not job.superseeded_by == self:
+ continue
- SELECT
- *
- FROM
- preceeding_jobs jobs
- WHERE
- jobs.deleted_at IS NULL
- ORDER BY
- jobs.created_at DESC
- """, self.id)
+ jobs.append(job)
+ jobs.extend(job.preceeding_jobs)
- return list(jobs)
+ return sorted(jobs)
@property
def all_jobs(self):
return False
+ def show_log(self):
+ """
+ Helper function because we cannot use any() in the templates.
+
+ Is returns True if we should show the "View Log" option.
+ """
+ if self.is_running():
+ return True
+
+ return any(job.has_log() for job in self.all_jobs)
+
@property
def log_url(self):
return self.backend.path_to_url(self.log_path)
</div>
</div>
- {% set has_log = False %}
-
- {# Does at last one job have a log? #}
- {% for job in job.all_jobs %}
- {% if job.has_log() %}
- {% set has_log = True %}
- {% endif %}
- {% endfor %}
-
<div class="level-right">
<div class="level-item">
<div class="buttons are-small">
- {% if has_log or job.is_running() %}
+ {% if job.show_log() %}
{% if job.preceeding_jobs %}
<div class="dropdown is-up is-right">
<div class="dropdown-trigger">