From 7c616aaf1ac8e7515ff8ede7fc0978c74d8235d6 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 3 Mar 2009 18:07:31 +0000 Subject: [PATCH] --- src/Hydra/lib/Hydra/Controller/Root.pm | 40 +++++++++++++++----------- src/Hydra/root/common.tt | 4 +-- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/Hydra/lib/Hydra/Controller/Root.pm b/src/Hydra/lib/Hydra/Controller/Root.pm index c098c8a1..6cbb4bc7 100644 --- a/src/Hydra/lib/Hydra/Controller/Root.pm +++ b/src/Hydra/lib/Hydra/Controller/Root.pm @@ -92,17 +92,25 @@ sub queue :Local { # Return the latest build for each job. sub getLatestBuilds { - my ($c, $builds) = @_; - return $builds->search({}, - { join => 'resultInfo' - , where => { - finished => { "!=", 0 }, - timestamp => \ ( - "= (select max(timestamp) from Builds " . - "where project == me.project and attrName == me.attrName and finished != 0 and system == me.system)"), - } - , order_by => "project, attrname, system" - }); + my ($c, $builds, $extraAttrs) = @_; + + my @res = (); + + foreach my $job ($builds->search({}, + {group_by => ['project', 'attrname', 'system']})) + { + my $attrs = + { project => $job->get_column('project') + , 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'; # 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"; - my @builds = getLatestBuilds($c, $c->model('DB::Builds')); # !!! this includes failed builds + my @builds = @{getLatestBuilds($c, $c->model('DB::Builds'), {buildStatus => 0})}; my @storePaths = (); foreach my $build (@builds) { # !!! better do this in getLatestBuilds with a join. - next unless $build->buildproducts->find({type => "nix-build"}); - push @storePaths, $build->outpath if isValidPath($build->outpath); - + next unless $build->buildproducts->find({type => "nix-build"}); + next unless isValidPath($build->outpath); + push @storePaths, $build->outpath; my $pkgName = $build->nixname . "-" . $build->system . "-" . $build->id . ".nixpkg"; $c->stash->{nixPkgs}->{$pkgName} = $build; }; diff --git a/src/Hydra/root/common.tt b/src/Hydra/root/common.tt index 0269b78e..64cd0b25 100644 --- a/src/Hydra/root/common.tt +++ b/src/Hydra/root/common.tt @@ -56,8 +56,8 @@ [% IF showSchedulingInfo %] [% build.schedulingInfo.priority %] [% END %] - [% build.project.name %] - [% build.attrname %] + [% build.get_column("project") %] + [% build.attrname %] [% build.resultInfo.releasename ? build.resultInfo.releasename : build.nixname %] [% build.system %] [% date.format(build.timestamp, '%Y-%m-%d %H:%M:%S') %]