On aggregate job pages, show a matrix showing all the constituent builds

This commit is contained in:
Eelco Dolstra 2013-08-26 18:58:04 +02:00
parent bf42392fe4
commit 7725038821
2 changed files with 92 additions and 2 deletions

View file

@ -20,15 +20,16 @@ sub job : Chained('/') PathPart('job') CaptureArgs(3) {
sub overview : Chained('job') PathPart('') Args(0) { sub overview : Chained('job') PathPart('') Args(0) {
my ($self, $c) = @_; my ($self, $c) = @_;
my $job = $c->stash->{job};
$c->stash->{template} = 'job.tt'; $c->stash->{template} = 'job.tt';
$c->stash->{lastBuilds} = $c->stash->{lastBuilds} =
[ $c->stash->{job}->builds->search({ finished => 1 }, [ $job->builds->search({ finished => 1 },
{ order_by => 'id DESC', rows => 10, columns => [@buildListColumns] }) ]; { order_by => 'id DESC', rows => 10, columns => [@buildListColumns] }) ];
$c->stash->{queuedBuilds} = [ $c->stash->{queuedBuilds} = [
$c->stash->{job}->builds->search( $job->builds->search(
{ finished => 0 }, { finished => 0 },
{ join => ['project'] { join => ['project']
, order_by => ["priority DESC", "id"] , order_by => ["priority DESC", "id"]
@ -36,6 +37,27 @@ sub overview : Chained('job') PathPart('') Args(0) {
, '+as' => ['enabled'] , '+as' => ['enabled']
} }
) ]; ) ];
# If this is an aggregate job, then get its constituents.
my @constituents = $c->model('DB::Builds')->search(
{ aggregate => { -in => $job->builds->search({}, { columns => ["id"], order_by => "id desc", rows => 10 })->as_query } },
{ join => 'aggregateconstituents_constituents',
columns => ['id', 'job', 'finished', 'buildstatus'],
+select => ['aggregateconstituents_constituents.aggregate'],
+as => ['aggregate']
});
my $aggregates = {};
my %constituentJobs;
foreach my $b (@constituents) {
my $jobName = $b->get_column('job');
$aggregates->{$b->get_column('aggregate')}->{$jobName} =
{ id => $b->id, finished => $b->finished, buildstatus => $b->buildstatus};
$constituentJobs{$jobName} = 1;
}
$c->stash->{aggregates} = $aggregates;
$c->stash->{constituentJobs} = [sort (keys %constituentJobs)];
} }

View file

@ -4,6 +4,9 @@
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li class="active"><a href="#tabs-status" data-toggle="tab">Status</a></li> <li class="active"><a href="#tabs-status" data-toggle="tab">Status</a></li>
[% IF constituentJobs.size > 0 %]
<li><a href="#tabs-constituents" data-toggle="tab">Constituents</a></li>
[% END %]
<li><a href="#tabs-links" data-toggle="tab">Links</a></li> <li><a href="#tabs-links" data-toggle="tab">Links</a></li>
</ul> </ul>
@ -21,6 +24,71 @@
[% END %] [% END %]
</div> </div>
[% IF constituentJobs.size > 0 %]
<div id="tabs-constituents" class="tab-pane">
<table class="table table-striped table-condensed">
<thead>
<tr>
<th>#</th>
[% FOREACH j IN constituentJobs %]
<th>[% HTML.escape(j) %]</th>
[% END %]
</tr>
</thead>
<tbody>
[% FOREACH agg IN aggregates.keys.nsort.reverse %]
<tr>
<td><a class="row-link" href="[% c.uri_for('/build' agg) %]">[% agg %]</a></td>
[% FOREACH j IN constituentJobs %]
<td>
[% r = aggregates.$agg.$j; IF r.id %]
<a href="[% c.uri_for('/build' r.id) %]">
[% INCLUDE renderBuildStatusIcon size=16 build=r %]
</a>
[% END %]
</td>
[% END %]
</tr>
[% END %]
</tbody>
</table>
<hr/>
<table class="table table-striped table-condensed">
<thead>
<tr>
<th>#</th>
[% FOREACH j IN constituentJobs %]
<th>[% HTML.escape(j) %]</th>
[% END %]
</tr>
</thead>
<tbody>
[% FOREACH agg IN aggregates.keys.nsort.reverse %]
<tr>
<td><a class="row-link" href="[% c.uri_for('/build' agg) %]">[% agg %]</a></td>
[% FOREACH j IN constituentJobs %]
<td>
[% r = aggregates.$agg.$j; IF r.id %]
<a href="[% c.uri_for('/build' r.id) %]">
[% INCLUDE renderBuildStatusIcon size=16 build=r %]
</a>
[% END %]
</td>
[% END %]
</tr>
[% END %]
</tbody>
</table>
</div>
[% END %]
<div id="tabs-links" class="tab-pane"> <div id="tabs-links" class="tab-pane">
<ul> <ul>
<li><a href="[% c.uri_for('/job' project.name jobset.name job.name 'latest') %]">Latest successful build</a></li> <li><a href="[% c.uri_for('/job' project.name jobset.name job.name 'latest') %]">Latest successful build</a></li>