This commit is contained in:
Eelco Dolstra 2009-03-03 18:07:31 +00:00
parent 4044e857b6
commit 7c616aaf1a
2 changed files with 26 additions and 18 deletions

View file

@ -92,17 +92,25 @@ sub queue :Local {
# Return the latest build for each job. # Return the latest build for each job.
sub getLatestBuilds { sub getLatestBuilds {
my ($c, $builds) = @_; my ($c, $builds, $extraAttrs) = @_;
return $builds->search({},
{ join => 'resultInfo' my @res = ();
, where => {
finished => { "!=", 0 }, foreach my $job ($builds->search({},
timestamp => \ ( {group_by => ['project', 'attrname', 'system']}))
"= (select max(timestamp) from Builds " . {
"where project == me.project and attrName == me.attrName and finished != 0 and system == me.system)"), my $attrs =
} { project => $job->get_column('project')
, order_by => "project, attrname, system" , attrname => $job->attrname
}); , system => $job->system
, finished => 1
};
my ($build) = $builds->search({ %$attrs, %$extraAttrs },
{ join => 'resultInfo', order_by => 'timestamp DESC', rows => 1 } );
push @res, $build if defined $build;
}
return [@res];
} }
@ -111,7 +119,7 @@ sub showJobStatus {
$c->stash->{template} = 'jobstatus.tt'; $c->stash->{template} = 'jobstatus.tt';
# Get the latest finished build for each unique job. # Get the latest finished build for each unique job.
$c->stash->{latestBuilds} = [getLatestBuilds($c, $builds)]; $c->stash->{latestBuilds} = getLatestBuilds($c, $builds, {});
} }
@ -534,14 +542,14 @@ sub nix : Chained('/') PathPart('channel/latest') CaptureArgs(0) {
$c->stash->{channelName} = "hydra-all-latest"; $c->stash->{channelName} = "hydra-all-latest";
my @builds = getLatestBuilds($c, $c->model('DB::Builds')); # !!! this includes failed builds my @builds = @{getLatestBuilds($c, $c->model('DB::Builds'), {buildStatus => 0})};
my @storePaths = (); my @storePaths = ();
foreach my $build (@builds) { foreach my $build (@builds) {
# !!! better do this in getLatestBuilds with a join. # !!! better do this in getLatestBuilds with a join.
next unless $build->buildproducts->find({type => "nix-build"}); next unless $build->buildproducts->find({type => "nix-build"});
push @storePaths, $build->outpath if isValidPath($build->outpath); next unless isValidPath($build->outpath);
push @storePaths, $build->outpath;
my $pkgName = $build->nixname . "-" . $build->system . "-" . $build->id . ".nixpkg"; my $pkgName = $build->nixname . "-" . $build->system . "-" . $build->id . ".nixpkg";
$c->stash->{nixPkgs}->{$pkgName} = $build; $c->stash->{nixPkgs}->{$pkgName} = $build;
}; };

View file

@ -56,8 +56,8 @@
[% IF showSchedulingInfo %] [% IF showSchedulingInfo %]
<td>[% build.schedulingInfo.priority %]</td> <td>[% build.schedulingInfo.priority %]</td>
[% END %] [% END %]
<td><a href="[% c.uri_for('/project' build.project.name) %]"><tt>[% build.project.name %]</tt></a></td> <td><a href="[% c.uri_for('/project' build.get_column("project")) %]"><tt>[% build.get_column("project") %]</tt></a></td>
<td><a href="[% c.uri_for('/job' build.project.name build.attrname) %]"><tt>[% build.attrname %]</tt></a></td> <td><a href="[% c.uri_for('/job' build.get_column("project") build.attrname) %]"><tt>[% build.attrname %]</tt></a></td>
<td>[% build.resultInfo.releasename ? build.resultInfo.releasename : build.nixname %]</td> <td>[% build.resultInfo.releasename ? build.resultInfo.releasename : build.nixname %]</td>
<td><tt>[% build.system %]</tt></td> <td><tt>[% build.system %]</tt></td>
<td>[% date.format(build.timestamp, '%Y-%m-%d %H:%M:%S') %]</td> <td>[% date.format(build.timestamp, '%Y-%m-%d %H:%M:%S') %]</td>