From 410060ec8ae12f3304158afaf1c87ea35c09e33f Mon Sep 17 00:00:00 2001
From: Eelco Dolstra
Date: Wed, 28 Aug 2013 09:59:02 +0000
Subject: [PATCH] Jobset page: Add a new tab to show job status in a matrix
---
src/lib/Hydra/Controller/Job.pm | 2 +-
src/lib/Hydra/Controller/Jobset.pm | 38 ++++++++++++++++++++---
src/root/jobset-job-status-tab.tt | 49 ++++++++++++++++++++++++++++++
src/root/jobset-jobs-tab.tt | 28 +++++++++--------
src/root/jobset.tt | 7 +++--
5 files changed, 105 insertions(+), 19 deletions(-)
create mode 100644 src/root/jobset-job-status-tab.tt
diff --git a/src/lib/Hydra/Controller/Job.pm b/src/lib/Hydra/Controller/Job.pm
index 4d186974..060e2424 100644
--- a/src/lib/Hydra/Controller/Job.pm
+++ b/src/lib/Hydra/Controller/Job.pm
@@ -52,7 +52,7 @@ sub overview : Chained('job') PathPart('') Args(0) {
foreach my $b (@constituents) {
my $jobName = $b->get_column('job');
$aggregates->{$b->get_column('aggregate')}->{constituents}->{$jobName} =
- { id => $b->id, finished => $b->finished, buildstatus => $b->buildstatus};
+ { id => $b->id, finished => $b->finished, buildstatus => $b->buildstatus };
$constituentJobs{$jobName} = 1;
}
diff --git a/src/lib/Hydra/Controller/Jobset.pm b/src/lib/Hydra/Controller/Jobset.pm
index 437b6bb5..9264366b 100644
--- a/src/lib/Hydra/Controller/Jobset.pm
+++ b/src/lib/Hydra/Controller/Jobset.pm
@@ -155,24 +155,54 @@ sub jobs_tab : Chained('jobsetChain') PathPart('jobs-tab') Args(0) {
{ hasnewbuilds => 1 }, { rows => 1, order_by => ["id desc"] })->single;
my %activeJobs;
+ $c->stash->{activeJobs} = {};
if (defined $latestEval) {
foreach my $build ($latestEval->builds->search({}, { order_by => ["job"], select => ["job"] })) {
my $job = $build->get_column("job");
if (!defined $activeJobs{$job}) {
$activeJobs{$job} = 1;
- push @{$c->stash->{activeJobs}}, $job;
+ $c->stash->{activeJobs}->{$job} = 1;
}
}
}
foreach my $job ($c->stash->{jobset}->jobs->search({}, { order_by => ["name"] })) {
- if (!defined $activeJobs{$job->name}) {
- push @{$c->stash->{inactiveJobs}}, $job->name;
- }
+ push @{$c->stash->{jobs}}, $job->name;
}
}
+sub job_status_tab : Chained('jobsetChain') PathPart('job-status-tab') Args(0) {
+ my ($self, $c) = @_;
+ $c->stash->{template} = 'jobset-job-status-tab.tt';
+
+ $c->stash->{filter} = $c->request->params->{filter} // "";
+
+ my @evals = $c->stash->{jobset}->jobsetevals->search({ hasnewbuilds => 1}, { order_by => "id desc", rows => 20 });
+
+ my $evals = {};
+ my %jobs;
+ my $nrBuilds = 0;
+
+ foreach my $eval (@evals) {
+ my @builds = $eval->builds->search(
+ { job => { ilike => "%" . $c->stash->{filter} . "%" } },
+ { columns => ['id', 'job', 'finished', 'buildstatus'] });
+ foreach my $b (@builds) {
+ my $jobName = $b->get_column('job');
+ $evals->{$eval->id}->{$jobName} =
+ { id => $b->id, finished => $b->finished, buildstatus => $b->buildstatus };
+ $jobs{$jobName} = 1;
+ $nrBuilds++;
+ }
+ last if $nrBuilds >= 10000;
+ }
+
+ $c->stash->{evals} = $evals;
+ $c->stash->{jobs} = [sort (keys %jobs)];
+}
+
+
# Hydra::Base::Controller::ListBuilds needs this.
sub get_builds : Chained('jobsetChain') PathPart('') CaptureArgs(0) {
my ($self, $c) = @_;
diff --git a/src/root/jobset-job-status-tab.tt b/src/root/jobset-job-status-tab.tt
new file mode 100644
index 00000000..2d04c306
--- /dev/null
+++ b/src/root/jobset-job-status-tab.tt
@@ -0,0 +1,49 @@
+[% PROCESS common.tt; USE Math %]
+
+
+
+
+
+[% IF jobs.size == 0 %]
+
+ There are no matching jobs.
+
+[% ELSE %]
+
+ [% evalIds = evals.keys.nsort.reverse %]
+
+
+[% END %]
diff --git a/src/root/jobset-jobs-tab.tt b/src/root/jobset-jobs-tab.tt
index 51a810a3..368bc7c6 100644
--- a/src/root/jobset-jobs-tab.tt
+++ b/src/root/jobset-jobs-tab.tt
@@ -1,15 +1,19 @@
[% PROCESS common.tt %]
-This jobset currently contains the following [% activeJobs.size %] jobs:
-
- [% IF activeJobs.size == 0 %](none)[% END %]
- [% FOREACH j IN activeJobs %][% INCLUDE renderJobName project=project.name jobset=jobset.name job=j %]
[% END %]
-
-
+[% IF jobs.size == 0 %]
+ This jobset has no jobs yet.
+[% ELSE %]
+ Below is the list of all [% jobs.size
+ %] jobs that have ever existed in this jobset. Jobs that are no
+ longer part of the jobset (i.e., that don't appear in the latest
+ evaluation of the jobset) are grayed out.
-This jobset used to contain the following [% inactiveJobs.size %] jobs:
-
- [% IF inactiveJobs.size == 0 %](none)[% END %]
- [% FOREACH j IN inactiveJobs %][% INCLUDE renderJobName project=project.name jobset=jobset.name job=j %]
[% END %]
-
-
+
+
+ Job name |
+
+
+ [% FOREACH j IN jobs %][% INCLUDE renderJobName project=project.name jobset=jobset.name job=j %] |
[% END %]
+
+
+[% END %]
diff --git a/src/root/jobset.tt b/src/root/jobset.tt
index d24f0880..2182bc9f 100644
--- a/src/root/jobset.tt
+++ b/src/root/jobset.tt
@@ -43,9 +43,10 @@
@@ -140,6 +141,8 @@
[% INCLUDE makeLazyTab tabName="tabs-jobs" uri=c.uri_for('/jobset' project.name jobset.name "jobs-tab") %]
+ [% INCLUDE makeLazyTab tabName="tabs-job-status" uri=c.uri_for('/jobset' project.name jobset.name "job-status-tab") %]
+
[% END %]