From: Michael Tremer Date: Thu, 26 Oct 2017 16:26:41 +0000 (+0100) Subject: web: Refactor job queue X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fe9b927c3c6437034d1b4ec54db032a95699aefd;p=pbs.git web: Refactor job queue Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index 9a496541..7b5d6720 100644 --- a/Makefile.am +++ b/Makefile.am @@ -182,8 +182,6 @@ dist_templates_DATA = \ src/templates/job-schedule-rebuild.html \ src/templates/job-schedule-test.html \ src/templates/jobs-detail.html \ - src/templates/jobs-filter.html \ - src/templates/jobs-index.html \ src/templates/keys-delete.html \ src/templates/keys-import.html \ src/templates/keys-list.html \ @@ -193,6 +191,7 @@ dist_templates_DATA = \ src/templates/package-detail-list.html \ src/templates/package-properties.html \ src/templates/packages-list.html \ + src/templates/queue.html \ src/templates/register-activation-fail.html \ src/templates/register-activation-success.html \ src/templates/register-fail.html \ diff --git a/po/POTFILES.in b/po/POTFILES.in index b57938b3..b14e2760 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -71,8 +71,6 @@ src/templates/jobs-buildroot.html src/templates/job-schedule-rebuild.html src/templates/job-schedule-test.html src/templates/jobs-detail.html -src/templates/jobs-filter.html -src/templates/jobs-index.html src/templates/keys-delete.html src/templates/keys-import.html src/templates/keys-list.html @@ -131,6 +129,7 @@ src/templates/packages/builds/times.html src/templates/packages/changelog.html src/templates/packages-list.html src/templates/packages/view-file.html +src/templates/queue.html src/templates/register-activation-fail.html src/templates/register-activation-success.html src/templates/register-fail.html diff --git a/src/templates/index.html b/src/templates/index.html index 93dc3777..da1c8ed8 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -73,7 +73,12 @@ {% end %} diff --git a/src/templates/jobs-filter.html b/src/templates/jobs-filter.html deleted file mode 100644 index 65f215b4..00000000 --- a/src/templates/jobs-filter.html +++ /dev/null @@ -1,63 +0,0 @@ -{% 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/src/templates/jobs-index.html b/src/templates/jobs-index.html deleted file mode 100644 index 58291ed9..00000000 --- a/src/templates/jobs-index.html +++ /dev/null @@ -1,55 +0,0 @@ -{% 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/src/templates/queue.html b/src/templates/queue.html new file mode 100644 index 00000000..5ad565fa --- /dev/null +++ b/src/templates/queue.html @@ -0,0 +1,41 @@ +{% extends "base.html" %} + +{% block title %}{{ _("Job Queue") }} - {{ arch or _("All Architectures") }}{% end block %} + +{% block body %} + + + + + + + {% module JobsList(queue) %} +{% end block %} diff --git a/src/web/__init__.py b/src/web/__init__.py index 4cf457b2..3069997a 100644 --- a/src/web/__init__.py +++ b/src/web/__init__.py @@ -160,9 +160,10 @@ class Application(tornado.web.Application): (r"/build/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})/watchers", builds.BuildWatchersHandler), (r"/build/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})/delete", builds.BuildDeleteHandler), + (r"/queue", jobs.ShowQueueHandler), + (r"/queue/([\w_]+)", jobs.ShowQueueHandler), + # Jobs - (r"/jobs", jobs.JobsIndexHandler), - (r"/jobs/filter", jobs.JobsFilterHandler), (r"/job/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})", jobs.JobDetailHandler), (r"/job/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})/abort", jobs.JobAbortHandler), (r"/job/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})/buildroot", jobs.JobBuildrootHandler), diff --git a/src/web/base.py b/src/web/base.py index d3ceaa5c..6bf8c32e 100644 --- a/src/web/base.py +++ b/src/web/base.py @@ -76,6 +76,7 @@ class BaseHandler(tornado.web.RequestHandler): ns = tornado.web.RequestHandler.get_template_namespace(self) ns.update({ + "backend" : self.backend, "bugtracker" : self.pakfire.bugzilla, "hostname" : self.request.host, "format_date" : self.format_date, diff --git a/src/web/jobs.py b/src/web/jobs.py index f3f016cf..f17817bb 100644 --- a/src/web/jobs.py +++ b/src/web/jobs.py @@ -4,36 +4,17 @@ import tornado.web from . import base -class JobsIndexHandler(base.BaseHandler): - def get(self): - # Filter for a certain arch. - arch = self.get_argument("arch", None) - if not arch or not self.backend.arches.exists(arch): - raise tornado.web.HTTPError(400, "Architecture does not exist") - - # 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) +class ShowQueueHandler(base.BaseHandler): + def get(self, arch=None): + if arch: + if not self.backend.arches.exists(arch): + raise tornado.web.HTTPError(400, "Architecture does not exist") - self.render("jobs-index.html", jobs=jobs, arch=arch, builder=builder, - date=date) - - -class JobsFilterHandler(base.BaseHandler): - def get(self): - builders = self.pakfire.builders.get_all() + queue = self.backend.jobqueue.for_arches([arch, "noarch"]) + else: + queue = self.backend.jobqueue - self.render("jobs-filter.html", arches=self.backend.arches, builders=builders) + self.render("queue.html", arch=arch, queue=queue) class JobDetailHandler(base.BaseHandler):