From d886ff99737bc17d1f860ea545f7bc3ba49fbfb2 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 28 Aug 2013 12:22:16 +0000 Subject: [PATCH] Integrate the "Job status" and "All jobs" tabs The job status tabs now has a toggle to show inactive jobs, rendering the "All jobs" tab redundant. --- src/lib/Hydra/Controller/Jobset.pm | 39 +++++------------ src/root/jobset-job-status-tab.tt | 59 ------------------------- src/root/jobset-jobs-tab.tt | 70 +++++++++++++++++++++++++----- src/root/jobset.tt | 5 +-- 4 files changed, 71 insertions(+), 102 deletions(-) delete mode 100644 src/root/jobset-job-status-tab.tt diff --git a/src/lib/Hydra/Controller/Jobset.pm b/src/lib/Hydra/Controller/Jobset.pm index 46041d6d..16f8ceda 100644 --- a/src/lib/Hydra/Controller/Jobset.pm +++ b/src/lib/Hydra/Controller/Jobset.pm @@ -148,35 +148,8 @@ sub jobs_tab : Chained('jobsetChain') PathPart('jobs-tab') Args(0) { my ($self, $c) = @_; $c->stash->{template} = 'jobset-jobs-tab.tt'; - $c->stash->{activeJobs} = []; - $c->stash->{inactiveJobs} = []; - - my $latestEval = $c->stash->{jobset}->jobsetevals->search( - { 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; - $c->stash->{activeJobs}->{$job} = 1; - } - } - } - - foreach my $job ($c->stash->{jobset}->jobs->search({}, { order_by => ["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 $filter = "%" . $c->stash->{filter} . "%"; my @evals = $c->stash->{jobset}->jobsetevals->search({ hasnewbuilds => 1}, { order_by => "id desc", rows => 20 }); @@ -186,7 +159,7 @@ sub job_status_tab : Chained('jobsetChain') PathPart('job-status-tab') Args(0) { foreach my $eval (@evals) { my @builds = $eval->builds->search( - { job => { ilike => "%" . $c->stash->{filter} . "%" } }, + { job => { ilike => $filter } }, { columns => ['id', 'job', 'finished', 'buildstatus'] }); foreach my $b (@builds) { my $jobName = $b->get_column('job'); @@ -198,6 +171,14 @@ sub job_status_tab : Chained('jobsetChain') PathPart('job-status-tab') Args(0) { last if $nrBuilds >= 10000; } + if ($c->request->params->{showInactive}) { + $c->stash->{showInactive} = 1; + foreach my $job ($c->stash->{jobset}->jobs->search({ name => { ilike => $filter } })) { + next if defined $jobs{$job->name}; + $c->stash->{inactiveJobs}->{$job->name} = $jobs{$job->name} = 1; + } + } + $c->stash->{evals} = $evals; my @jobs = sort (keys %jobs); $c->stash->{nrJobs} = scalar @jobs; diff --git a/src/root/jobset-job-status-tab.tt b/src/root/jobset-job-status-tab.tt deleted file mode 100644 index f1f5a160..00000000 --- a/src/root/jobset-job-status-tab.tt +++ /dev/null @@ -1,59 +0,0 @@ -[% PROCESS common.tt; USE Math %] - - - - - -[% IF jobs.size == 0 %] - -
There are no matching jobs.
- -[% ELSE %] - - [% IF nrJobs > jobs.size %] -
Showing the first [% jobs.size %] jobs only. Show all [% nrJobs %] jobs...
- [% END %] - - [% evalIds = evals.keys.nsort.reverse %] - - - - - [% FOREACH eval IN evalIds %] - - [% END %] - - - - [% FOREACH j IN jobs-%] - - - [% FOREACH eval IN evalIds %] - - [% END %] - - [% END %] - -
Job -
[% INCLUDE renderJobName project=project.name jobset=jobset.name job=j %][% r = evals.$eval.$j; IF r.id %][% INCLUDE renderBuildStatusIcon size=16 build=r %][% END %]
- -[% END %] diff --git a/src/root/jobset-jobs-tab.tt b/src/root/jobset-jobs-tab.tt index 368bc7c6..b27a084d 100644 --- a/src/root/jobset-jobs-tab.tt +++ b/src/root/jobset-jobs-tab.tt @@ -1,19 +1,69 @@ -[% PROCESS common.tt %] +[% PROCESS common.tt; USE Math %] + + + + [% 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.
- +
There are no matching jobs.
+ +[% ELSE %] + + [% IF nrJobs > jobs.size %] +
Showing the first [% jobs.size %] jobs. Show all [% nrJobs %] jobs...
+ [% END %] + + [% evalIds = evals.keys.nsort.reverse %] +
- + + + [% FOREACH eval IN evalIds %] + + [% END %] + - [% FOREACH j IN jobs %][% END %] + [% FOREACH j IN jobs-%] + + + [% FOREACH eval IN evalIds %] + + [% END %] + + [% END %]
Job name
Job +
[% INCLUDE renderJobName project=project.name jobset=jobset.name job=j %]
[% INCLUDE renderJobName project=project.name jobset=jobset.name job=j %][% r = evals.$eval.$j; IF r.id %][% INCLUDE renderBuildStatusIcon size=16 build=r %][% END %]
+ [% END %] diff --git a/src/root/jobset.tt b/src/root/jobset.tt index 2182bc9f..2363d759 100644 --- a/src/root/jobset.tt +++ b/src/root/jobset.tt @@ -45,8 +45,7 @@ [% IF jobset.errormsg %]
  • Evaluation errors
  • [% END %] -
  • Job status
  • -
  • All jobs
  • +
  • Jobs
  • Configuration
  • @@ -141,8 +140,6 @@ [% 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 %]