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;
|
|
|
|
|
|
|
|
|
2009-04-25 11:41:46 +00:00
|
|
|
sub getJobStatus {
|
|
|
|
my ($self, $c) = @_;
|
2013-01-22 13:41:02 +00:00
|
|
|
|
2010-09-08 06:37:19 +00:00
|
|
|
my $maintainer = $c->request->params->{"maintainer"};
|
|
|
|
|
2012-03-05 20:52:47 +00:00
|
|
|
my $latest = $c->stash->{jobStatus}->search(
|
2010-09-08 06:37:19 +00:00
|
|
|
defined $maintainer ? { maintainers => { like => "%$maintainer%" } } : {},
|
2012-03-05 20:52:47 +00:00
|
|
|
{ '+select' => ["me.statusChangeId", "me.statusChangeTime"]
|
|
|
|
, '+as' => ["statusChangeId", "statusChangeTime"]
|
2009-07-09 15:26:55 +00:00
|
|
|
, order_by => "coalesce(statusChangeTime, 0) desc"
|
2009-07-09 14:48:15 +00:00
|
|
|
});
|
|
|
|
|
2009-04-15 14:50:15 +00:00
|
|
|
return $latest;
|
|
|
|
}
|
|
|
|
|
2013-02-14 12:23:54 +00:00
|
|
|
|
2009-03-04 10:59:14 +00:00
|
|
|
sub jobstatus : Chained('get_builds') PathPart Args(0) {
|
|
|
|
my ($self, $c) = @_;
|
2009-03-04 17:24:08 +00:00
|
|
|
$c->stash->{template} = 'jobstatus.tt';
|
2009-04-15 14:50:15 +00:00
|
|
|
$c->stash->{latestBuilds} = [getJobStatus($self, $c)->all];
|
2009-03-04 10:59:14 +00:00
|
|
|
}
|
|
|
|
|
2009-04-08 22:08:00 +00:00
|
|
|
|
2013-02-14 12:23:54 +00:00
|
|
|
|
2009-04-08 22:08:00 +00:00
|
|
|
# A convenient way to see all the errors - i.e. things demanding
|
2013-01-22 13:41:02 +00:00
|
|
|
# attention - at a glance.
|
2009-04-08 22:08:00 +00:00
|
|
|
sub errors : Chained('get_builds') PathPart Args(0) {
|
|
|
|
my ($self, $c) = @_;
|
|
|
|
$c->stash->{template} = 'errors.tt';
|
|
|
|
$c->stash->{brokenJobsets} =
|
|
|
|
[$c->stash->{allJobsets}->search({errormsg => {'!=' => ''}})]
|
|
|
|
if defined $c->stash->{allJobsets};
|
|
|
|
$c->stash->{brokenJobs} =
|
|
|
|
[$c->stash->{allJobs}->search({errormsg => {'!=' => ''}})]
|
|
|
|
if defined $c->stash->{allJobs};
|
|
|
|
$c->stash->{brokenBuilds} =
|
2012-03-05 20:52:47 +00:00
|
|
|
[getJobStatus($self, $c)->search({buildStatus => {'!=' => 0}})];
|
2009-04-08 22:08:00 +00:00
|
|
|
}
|
|
|
|
|
2013-01-22 13:41:02 +00:00
|
|
|
|
2009-03-04 10:59:14 +00:00
|
|
|
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
|
|
|
|
2010-02-09 14:08:45 +00:00
|
|
|
my $nrBuilds = $c->stash->{allBuilds}->search({finished => 1})->count;
|
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;
|
2012-04-02 14:11:22 +00:00
|
|
|
$c->stash->{total} = $nrBuilds;
|
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
|
|
|
|
2009-04-08 08:09:39 +00:00
|
|
|
$c->res->redirect($c->uri_for($c->controller('Build')->action_for("view_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
|
|
|
|
2009-04-08 08:09:39 +00:00
|
|
|
$c->res->redirect($c->uri_for($c->controller('Build')->action_for("view_build"), [$latest->id], @rest));
|
2009-04-07 15:49:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-04 10:59:14 +00:00
|
|
|
1;
|