def get_by_uuid(self, uuid):
return self._get_job("SELECT * FROM jobs WHERE uuid = %s", uuid)
- def get_finished(self, limit=None, offset=None):
+ def get_finished(self, failed_only=False, limit=None, offset=None):
"""
Returns an iterator of all finished jobs
"""
+ if failed_only:
+ return self._get_jobs("""
+ SELECT
+ *
+ FROM
+ jobs
+ WHERE
+ deleted_at IS NULL
+ AND
+ finished_at IS NOT NULL
+ AND
+ failed IS TRUE
+ ORDER BY
+ finished_at DESC
+ LIMIT
+ %s
+ OFFSET
+ %s
+ """, limit, offset)
+
return self._get_jobs("""
SELECT
*
</ul>
</nav>
- <h1 class="title">{{ _("Recent Jobs") }}</h1>
+ <h1 class="title">
+ {% if failed_only %}
+ {{ _("Recently Failed Jobs") }}
+ {% else %}
+ {{ _("Recent Jobs") }}
+ {% end %}
+ </h1>
+
+ <div class="buttons are-small">
+ <a class="button is-danger {% if not failed_only %}is-outlined{% end %}"
+ href="{{ make_url("/jobs", offset=max(offset - limit, 0), limit=limit, failed_only=not failed_only) }}">
+ {{ _("Failed") }}
+ </a>
+ </div>
</div>
</div>
</section>
<div class="block">
<nav class="pagination is-centered" role="navigation" aria-label="pagination">
<a class="pagination-previous {% if not offset %}is-disabled{% end %}"
- href="{{ make_url("/jobs", offset=offset - limit, limit=limit) }}">
+ href="{{ make_url("/jobs", offset=offset - limit, limit=limit, failed_only=failed_only) }}">
{{ _("Previous Page") }}
</a>
<a class="pagination-next"
- href="{{ make_url("/jobs", offset=offset + limit, limit=limit) }}">
+ href="{{ make_url("/jobs", offset=offset + limit, limit=limit, failed_only=failed_only) }}">
{{ _("Next Page") }}
</a>
</nav>
offset = self.get_argument_int("offset", None) or 0
limit = self.get_argument_int("limit", None) or 50
+ # Filter
+ failed_only = self.get_argument_bool("failed_only")
+
with self.db.transaction():
- jobs = self.backend.jobs.get_finished(limit=limit, offset=offset)
+ jobs = self.backend.jobs.get_finished(failed_only=failed_only,
+ limit=limit, offset=offset)
# Group jobs by date
jobs = misc.group(jobs, lambda job: job.finished_at.date())
- self.render("jobs/index.html", jobs=jobs, limit=limit, offset=offset)
+ self.render("jobs/index.html", jobs=jobs, limit=limit, offset=offset,
+ failed_only=failed_only)
class LogHandler(base.BaseHandler):