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 20:11:34 +02: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 21:52:47 +01:00
|
|
|
$c->stash->{builds} = [ $c->stash->{allBuilds}->search(
|
2009-03-23 13:52:24 +00:00
|
|
|
{ finished => 1 },
|
2013-05-23 10:45:49 -04:00
|
|
|
{ order_by => "stoptime DESC"
|
2012-03-07 22:20:15 +01:00
|
|
|
, columns => [@buildListColumns]
|
2009-03-23 13:52:24 +00:00
|
|
|
, rows => $resultsPerPage
|
2011-11-29 19:55:49 +01:00
|
|
|
, page => $page }) ];
|
2009-03-04 10:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-04-25 03:53:57 +02:00
|
|
|
sub nix : Chained('get_builds') PathPart('channel/latest') CaptureArgs(1) {
|
2009-03-04 16:36:23 +00:00
|
|
|
my ($self, $c, $channelName) = @_;
|
2015-04-25 03:53:57 +02:00
|
|
|
|
|
|
|
$c->stash->{channelName} = $c->stash->{channelBaseName} . "-latest";
|
|
|
|
$c->stash->{channelBuilds} = $c->stash->{latestSucceeded}
|
|
|
|
->search_literal("exists (select 1 from buildproducts where build = me.id and type = 'nix-build')")
|
|
|
|
->search({}, { columns => [@buildListColumns, 'drvpath', 'description', 'homepage']
|
|
|
|
, join => ["buildoutputs"]
|
|
|
|
, order_by => ["me.id", "buildoutputs.name"]
|
|
|
|
, '+select' => ['buildoutputs.path', 'buildoutputs.name'], '+as' => ['outpath', 'outname'] });
|
2009-03-04 16:36:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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 12:18:38 -04: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 14:41:02 +01:00
|
|
|
|
2013-06-17 12:34:21 -04: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 14:41:02 +01:00
|
|
|
|
2013-05-23 12:18:38 -04: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 14:41:02 +01:00
|
|
|
|
2013-06-17 12:34:21 -04: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 22:17:04 +02: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;
|