2009-03-04 10:59:14 +00:00
|
|
|
package Hydra::Base::Controller::ListBuilds;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
2009-03-04 16:36:23 +00:00
|
|
|
use base 'Hydra::Base::Controller::NixChannel';
|
2009-03-04 10:59:14 +00:00
|
|
|
use Hydra::Helper::Nix;
|
|
|
|
use Hydra::Helper::CatalystUtils;
|
|
|
|
|
|
|
|
|
|
|
|
sub all : Chained('get_builds') PathPart {
|
2009-10-15 12:59:55 +00:00
|
|
|
my ($self, $c) = @_;
|
2009-03-04 10:59:14 +00:00
|
|
|
|
2010-02-09 15:51:33 +00:00
|
|
|
$c->stash->{template} = 'all.tt';
|
|
|
|
|
2010-02-09 14:10:16 +00:00
|
|
|
my $page = int($c->req->param('page') || "1") || 1;
|
2009-03-04 10:59:14 +00:00
|
|
|
|
2010-01-07 14:25:12 +00:00
|
|
|
my $resultsPerPage = 20;
|
2009-03-04 10:59:14 +00:00
|
|
|
|
|
|
|
$c->stash->{baseUri} = $c->uri_for($self->action_for("all"), $c->req->captures);
|
|
|
|
|
|
|
|
$c->stash->{page} = $page;
|
|
|
|
$c->stash->{resultsPerPage} = $resultsPerPage;
|
2013-08-12 18:11:34 +00:00
|
|
|
$c->stash->{total} = $c->stash->{allBuilds}->search({finished => 1})->count
|
|
|
|
unless defined $c->stash->{total};
|
2009-03-04 10:59:14 +00:00
|
|
|
|
2012-03-05 20:52:47 +00:00
|
|
|
$c->stash->{builds} = [ $c->stash->{allBuilds}->search(
|
2009-03-23 13:52:24 +00:00
|
|
|
{ finished => 1 },
|
2013-05-23 14:45:49 +00:00
|
|
|
{ order_by => "stoptime DESC"
|
2012-03-07 21:20:15 +00:00
|
|
|
, columns => [@buildListColumns]
|
2009-03-23 13:52:24 +00:00
|
|
|
, rows => $resultsPerPage
|
2011-11-29 18:55:49 +00:00
|
|
|
, page => $page }) ];
|
2009-03-04 10:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-04 16:36:23 +00:00
|
|
|
sub nix : Chained('get_builds') PathPart('channel') CaptureArgs(1) {
|
|
|
|
my ($self, $c, $channelName) = @_;
|
|
|
|
eval {
|
|
|
|
if ($channelName eq "latest") {
|
|
|
|
$c->stash->{channelName} = $c->stash->{channelBaseName} . "-latest";
|
2012-03-08 00:17:59 +00:00
|
|
|
$c->stash->{channelBuilds} = $c->stash->{latestSucceeded}
|
|
|
|
->search_literal("exists (select 1 from buildproducts where build = me.id and type = 'nix-build')")
|
2013-02-14 12:23:54 +00:00
|
|
|
->search({}, { columns => [@buildListColumns, 'drvpath', 'description', 'homepage']
|
|
|
|
, join => ["buildoutputs"]
|
2013-02-13 16:49:28 +00:00
|
|
|
, '+select' => ['buildoutputs.path', 'buildoutputs.name'], '+as' => ['outpath', 'outname'] });
|
2009-03-04 16:36:23 +00:00
|
|
|
}
|
|
|
|
else {
|
2010-02-05 20:08:41 +00:00
|
|
|
notFound($c, "Unknown channel `$channelName'.");
|
2009-03-04 16:36:23 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
error($c, $@) if $@;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-07 15:49:02 +00:00
|
|
|
# Redirect to the latest successful build.
|
|
|
|
sub latest : Chained('get_builds') PathPart('latest') {
|
2009-04-08 08:09:39 +00:00
|
|
|
my ($self, $c, @rest) = @_;
|
2009-04-07 15:49:02 +00:00
|
|
|
|
2013-05-23 16:18:38 +00:00
|
|
|
my $latest = $c->stash->{allBuilds}->find(
|
|
|
|
{ finished => 1, buildstatus => 0 }, { order_by => ["id DESC"], rows => 1 });
|
2009-04-07 15:49:02 +00:00
|
|
|
|
2009-04-09 15:09:00 +00:00
|
|
|
notFound($c, "There is no successful build to redirect to.") unless defined $latest;
|
2013-01-22 13:41:02 +00:00
|
|
|
|
2013-06-17 16:34:21 +00:00
|
|
|
$c->res->redirect($c->uri_for($c->controller('Build')->action_for("build"), [$latest->id], @rest));
|
2009-04-07 15:49:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Redirect to the latest successful build for a specific platform.
|
|
|
|
sub latest_for : Chained('get_builds') PathPart('latest-for') {
|
2009-04-08 08:09:39 +00:00
|
|
|
my ($self, $c, $system, @rest) = @_;
|
2009-04-07 15:49:02 +00:00
|
|
|
|
|
|
|
notFound($c, "You need to specify a platform type in the URL.") unless defined $system;
|
2013-01-22 13:41:02 +00:00
|
|
|
|
2013-05-23 16:18:38 +00:00
|
|
|
my $latest = $c->stash->{allBuilds}->find(
|
|
|
|
{ finished => 1, buildstatus => 0, system => $system }, { order_by => ["id DESC"], rows => 1 });
|
2009-04-07 15:49:02 +00:00
|
|
|
|
|
|
|
notFound($c, "There is no successful build for platform `$system' to redirect to.") unless defined $latest;
|
2013-01-22 13:41:02 +00:00
|
|
|
|
2013-06-17 16:34:21 +00:00
|
|
|
$c->res->redirect($c->uri_for($c->controller('Build')->action_for("build"), [$latest->id], @rest));
|
2009-04-07 15:49:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-12 20:17:04 +00:00
|
|
|
# Redirect to the latest successful build in a finished evaluation
|
|
|
|
# (i.e. an evaluation that has no unfinished builds).
|
|
|
|
sub latest_finished : Chained('get_builds') PathPart('latest-finished') {
|
|
|
|
my ($self, $c, @rest) = @_;
|
|
|
|
|
|
|
|
my $latest = $c->stash->{allBuilds}->find(
|
|
|
|
{ finished => 1, buildstatus => 0 },
|
|
|
|
{ order_by => ["id DESC"], rows => 1, join => ["jobsetevalmembers"]
|
|
|
|
, where => \
|
|
|
|
"not exists (select 1 from jobsetevalmembers m2 join builds b2 on jobsetevalmembers.eval = m2.eval and m2.build = b2.id and b2.finished = 0)"
|
|
|
|
});
|
|
|
|
|
|
|
|
notFound($c, "There is no successful build to redirect to.") unless defined $latest;
|
|
|
|
|
|
|
|
$c->res->redirect($c->uri_for($c->controller('Build')->action_for("build"), [$latest->id], @rest));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-04 10:59:14 +00:00
|
|
|
1;
|