From: Michael Tremer Date: Sat, 8 Dec 2012 20:36:53 +0000 (+0100) Subject: Add job overview page and option to filter them. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9177f86a8fc33e75247cb5c4971e2b64c05799f0;p=pbs.git Add job overview page and option to filter them. --- diff --git a/backend/arches.py b/backend/arches.py index eee8afea..cbb00b6b 100644 --- a/backend/arches.py +++ b/backend/arches.py @@ -3,10 +3,19 @@ import base class Arches(base.Object): - def get_all(self): - arches = self.db.query("SELECT id FROM arches WHERE `binary` = 'Y'") + def get_all(self, really=False): + query = "SELECT * FROM arches" - return sorted([Arch(self.pakfire, a.id) for a in arches]) + if not really: + query += " WHERE `binary` = 'Y'" + else: + query += " WHERE NOT name = 'src'" + + query += " ORDER BY prio ASC" + + arches = self.db.query(query) + + return [Arch(self.pakfire, a.id, a) for a in arches] def get_name_by_id(self, id): arch = self.db.get("SELECT name FROM arches WHERE id = %s", id) @@ -54,14 +63,14 @@ class Arches(base.Object): class Arch(base.Object): - def __init__(self, pakfire, id): + def __init__(self, pakfire, id, data=None): base.Object.__init__(self, pakfire) # The ID of this architecture. self.id = id # Cache data. - self._data = None + self._data = data def __cmp__(self, other): return cmp(self.prio, other.prio) diff --git a/backend/builds.py b/backend/builds.py index 078ef491..7701ad19 100644 --- a/backend/builds.py +++ b/backend/builds.py @@ -1328,30 +1328,30 @@ class Jobs(base.Object): return jobs - def get_latest(self, builder=None, limit=None, age=None, date=None): + def get_latest(self, arch=None, builder=None, limit=None, age=None, date=None): query = "SELECT * FROM jobs" args = [] where = ["(state = 'finished' OR state = 'failed' OR state = 'aborted')"] + + if arch: + where.append("arch_id = %s") + args.append(arch.id) + if builder: where.append("builder_id = %s") args.append(builder.id) if date: - year, month, day = date.split("-", 2) - try: + year, month, day = date.split("-", 2) date = datetime.date(int(year), int(month), int(day)) except ValueError: pass - else: - where.append("DATE(time_created) = %s") - args.append(date) - where.append("DATE(time_started) = %s") - args.append(date) - where.append("DATE(time_finished) = %s") - args.append(date) + where.append("(DATE(time_created) = %s OR \ + DATE(time_started) = %s OR DATE(time_finished) = %s)") + args += (date, date, date) if age: where.append("time_finished >= DATE_SUB(NOW(), INTERVAL %s)" % age) diff --git a/data/templates/builder-detail.html b/data/templates/builder-detail.html index 8ea27c50..ab1a8fbc 100644 --- a/data/templates/builder-detail.html +++ b/data/templates/builder-detail.html @@ -17,6 +17,59 @@ +
+ + {{ _("Actions") }} + + +
+ @@ -139,39 +192,6 @@ - {% if current_user and current_user.has_perm("maintain_builders") %} -
- -
- {% if builder.enabled %} - - {{ _("Disable builder") }} - - {% else %} - - {{ _("Enable builder") }} - - {% end %} - - - - {{ _("Edit builder") }} - - - {% if not builder.enabled %} - - - {{ _("Renew passphrase") }} - - {% end %} - - - - {{ _("Delete builder") }} - -
- {% end %} -

{{ _("Log") }}

diff --git a/data/templates/jobs-filter.html b/data/templates/jobs-filter.html new file mode 100644 index 00000000..65f215b4 --- /dev/null +++ b/data/templates/jobs-filter.html @@ -0,0 +1,63 @@ +{% extends "base.html" %} + +{% block title %}{{ _("Filter jobs") }}{% end block %} + +{% block body %} + + + + +
+
+
+ +
+ + + {{ _("Only show jobs, that have been built by this builder.") }} + +
+
+ +
+ +
+ +
+ + + {{ _("Only show jobs, with this architecture.") }} + +
+
+ +
+ +
+
+
+{% end block %} diff --git a/data/templates/jobs-index.html b/data/templates/jobs-index.html new file mode 100644 index 00000000..58291ed9 --- /dev/null +++ b/data/templates/jobs-index.html @@ -0,0 +1,55 @@ +{% extends "base.html" %} + +{% block title %}{{ _("Jobs") }}{% end block %} + +{% block body %} + + + + + + + {% if arch or builder or date %} + + +
+ {% end %} + + {% module JobsList(jobs) %} +{% end block %} diff --git a/web/__init__.py b/web/__init__.py index 02c8c82a..627dd8ea 100644 --- a/web/__init__.py +++ b/web/__init__.py @@ -144,6 +144,8 @@ class Application(tornado.web.Application): (r"/build/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})/delete", BuildDeleteHandler), # Jobs + (r"/jobs", JobsIndexHandler), + (r"/jobs/filter", JobsFilterHandler), (r"/job/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})", JobDetailHandler), (r"/job/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})/abort", JobAbortHandler), (r"/job/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})/buildroot", JobBuildrootHandler), diff --git a/web/handlers_jobs.py b/web/handlers_jobs.py index ba2411bb..12949f52 100644 --- a/web/handlers_jobs.py +++ b/web/handlers_jobs.py @@ -5,6 +5,41 @@ import tornado.web from handlers_base import BaseHandler +class JobsIndexHandler(BaseHandler): + def get(self): + # Filter for a certain arch. + arch_name = self.get_argument("arch", None) + if arch_name: + arch = self.pakfire.arches.get_by_name(arch_name) + else: + arch = None + + # Check if we need to filter for a certain builder. + builder_name = self.get_argument("builder", None) + if builder_name: + builder = self.pakfire.builders.get_by_name(builder_name) + else: + builder = None + + # Filter for a certain date. + date = self.get_argument("date", None) + + # Get all jobs, that fulfill the criteria. + jobs = self.pakfire.jobs.get_latest(limit=50, arch=arch, builder=builder, + date=date) + + self.render("jobs-index.html", jobs=jobs, arch=arch, builder=builder, + date=date) + + +class JobsFilterHandler(BaseHandler): + def get(self): + arches = self.pakfire.arches.get_all(really=True) + builders = self.pakfire.builders.get_all() + + self.render("jobs-filter.html", arches=arches, builders=builders) + + class JobDetailHandler(BaseHandler): def get(self, uuid): job = self.pakfire.jobs.get_by_uuid(uuid)