From 7b60aed5ed5133e759da3f7f1f9dff2ffd25ddd8 Mon Sep 17 00:00:00 2001 From: aszlig Date: Tue, 14 Apr 2015 08:58:55 +0200 Subject: [PATCH] jobset: Add a new "channels" tab. It's very similar to "jobs" and the code is pretty much the same, except that we don't do filtering on it. At least it doesn't waste space for a filter option when there are usually WAY less channel jobs than ordinary jobs. Signed-off-by: aszlig --- src/lib/Hydra/Controller/Jobset.pm | 40 ++++++++++++++++++++++++++++++ src/root/jobset-channels-tab.tt | 34 +++++++++++++++++++++++++ src/root/jobset.tt | 3 +++ 3 files changed, 77 insertions(+) create mode 100644 src/root/jobset-channels-tab.tt diff --git a/src/lib/Hydra/Controller/Jobset.pm b/src/lib/Hydra/Controller/Jobset.pm index 1d1cce63..d4a0eb5f 100644 --- a/src/lib/Hydra/Controller/Jobset.pm +++ b/src/lib/Hydra/Controller/Jobset.pm @@ -145,6 +145,46 @@ sub jobs_tab : Chained('jobsetChain') PathPart('jobs-tab') Args(0) { } +# XXX: Pretty much a rip-off of jobs-tab, make it DRY! +sub channels_tab : Chained('jobsetChain') PathPart('channels-tab') Args(0) { + my ($self, $c) = @_; + $c->stash->{template} = 'jobset-channels-tab.tt'; + + my @evals = $c->stash->{jobset}->jobsetevals->search( + { hasnewbuilds => 1}, + { order_by => "id desc", rows => 20 } + ); + + my $evals = {}; + my %channels; + + foreach my $eval (@evals) { + my @builds = $eval->builds->search( + { 'buildproducts.type' => 'file' + , 'buildproducts.subtype' => 'channel' }, + { join => ["buildproducts"] + , columns => ['id', 'job', 'finished', 'buildstatus'] } + ); + foreach my $b (@builds) { + my $jobName = $b->get_column('job'); + + $evals->{$eval->id}->{timestamp} = $eval->timestamp; + $evals->{$eval->id}->{channels}->{$jobName} = { + id => $b->id, + finished => $b->finished, + buildstatus => $b->buildstatus + }; + + $channels{$jobName} = 1; + } + } + + $c->stash->{evals} = $evals; + my @channels = sort (keys %channels); + $c->stash->{channels} = [@channels]; +} + + # Hydra::Base::Controller::ListBuilds needs this. sub get_builds : Chained('jobsetChain') PathPart('') CaptureArgs(0) { my ($self, $c) = @_; diff --git a/src/root/jobset-channels-tab.tt b/src/root/jobset-channels-tab.tt new file mode 100644 index 00000000..2a5f72a5 --- /dev/null +++ b/src/root/jobset-channels-tab.tt @@ -0,0 +1,34 @@ +[% PROCESS common.tt %] + +[% IF channels.size == 0 %] + +
There are no channels available.
+ +[% ELSE %] + + [% evalIds = evals.keys.nsort.reverse %] + + + + + [% FOREACH eval IN evalIds %] + + [% END %] + + + + [% FOREACH chan IN channels-%] + + + [% FOREACH eval IN evalIds %] + + [% END %] + + [% END %] + +
Channel +
[% INCLUDE renderJobName project=project.name jobset=jobset.name job=chan %][% r = evals.$eval.channels.$chan; IF r.id %][% INCLUDE renderBuildStatusIcon size=16 build=r %][% END %]
+ +[% END %] diff --git a/src/root/jobset.tt b/src/root/jobset.tt index 63ef29b9..04b0efaf 100644 --- a/src/root/jobset.tt +++ b/src/root/jobset.tt @@ -64,6 +64,7 @@
  • Jobs
  • Configuration
  • Links
  • +
  • Channels
  • @@ -165,6 +166,8 @@
    + [% INCLUDE makeLazyTab tabName="tabs-channels" uri=c.uri_for('/jobset' project.name jobset.name "channels-tab") %] +