2011-07-18 15:03:15 +00:00
|
|
|
|
package Hydra::Controller::Jobset;
|
2009-03-13 15:23:08 +00:00
|
|
|
|
|
2013-10-03 17:54:40 +02:00
|
|
|
|
use utf8;
|
2009-03-13 15:23:08 +00:00
|
|
|
|
use strict;
|
|
|
|
|
use warnings;
|
|
|
|
|
use base 'Hydra::Base::Controller::ListBuilds';
|
|
|
|
|
use Hydra::Helper::Nix;
|
|
|
|
|
use Hydra::Helper::CatalystUtils;
|
|
|
|
|
|
|
|
|
|
|
2013-06-17 12:34:21 -04:00
|
|
|
|
sub jobsetChain :Chained('/') :PathPart('jobset') :CaptureArgs(2) {
|
2009-03-13 15:23:08 +00:00
|
|
|
|
my ($self, $c, $projectName, $jobsetName) = @_;
|
|
|
|
|
|
2013-06-17 12:34:21 -04:00
|
|
|
|
my $project = $c->model('DB::Projects')->find($projectName);
|
|
|
|
|
|
2013-10-03 14:16:21 +02:00
|
|
|
|
notFound($c, "Project ‘$projectName’ doesn't exist.") if !$project;
|
2013-06-17 12:34:21 -04:00
|
|
|
|
|
2013-10-03 14:16:21 +02:00
|
|
|
|
$c->stash->{project} = $project;
|
2013-06-17 12:34:21 -04:00
|
|
|
|
|
2013-10-03 18:49:37 +02:00
|
|
|
|
$c->stash->{jobset} = $project->jobsets->find({ name => $jobsetName });
|
2013-10-03 14:16:21 +02:00
|
|
|
|
|
2014-04-23 23:12:00 +02:00
|
|
|
|
if (!$c->stash->{jobset} && !($c->action->name eq "jobset" and $c->request->method eq "PUT")) {
|
|
|
|
|
my $rename = $project->jobsetrenames->find({ from_ => $jobsetName });
|
|
|
|
|
notFound($c, "Jobset ‘$jobsetName’ doesn't exist.") unless defined $rename;
|
2014-04-24 10:52:46 +02:00
|
|
|
|
|
|
|
|
|
# Return a permanent redirect to the new jobset name.
|
|
|
|
|
my @captures = @{$c->req->captures};
|
|
|
|
|
$captures[1] = $rename->to_;
|
|
|
|
|
$c->res->redirect($c->uri_for($c->action, \@captures, $c->req->params), 301);
|
|
|
|
|
$c->detach;
|
2014-04-23 23:12:00 +02:00
|
|
|
|
}
|
2014-04-24 10:52:46 +02:00
|
|
|
|
|
|
|
|
|
$c->stash->{params}->{name} //= $jobsetName;
|
2009-03-13 15:23:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-02-21 17:59:36 +01:00
|
|
|
|
|
2013-06-17 12:34:21 -04:00
|
|
|
|
sub jobset :Chained('jobsetChain') :PathPart('') :Args(0) :ActionClass('REST::ForBrowsers') { }
|
|
|
|
|
|
|
|
|
|
sub jobset_GET {
|
2013-02-22 14:29:12 +01:00
|
|
|
|
my ($self, $c) = @_;
|
2009-03-13 15:23:08 +00:00
|
|
|
|
|
2009-04-02 16:15:57 +00:00
|
|
|
|
$c->stash->{template} = 'jobset.tt';
|
2011-05-16 08:03:06 +00:00
|
|
|
|
|
2013-02-22 14:29:12 +01:00
|
|
|
|
$c->stash->{evals} = getEvals($self, $c, scalar $c->stash->{jobset}->jobsetevals, 0, 10);
|
|
|
|
|
|
2013-09-21 14:47:52 +00:00
|
|
|
|
$c->stash->{latestEval} = $c->stash->{jobset}->jobsetevals->search({}, { rows => 1, order_by => ["id desc"] })->single;
|
|
|
|
|
|
|
|
|
|
$c->stash->{totalShares} = getTotalShares($c->model('DB')->schema);
|
2013-06-17 12:34:21 -04:00
|
|
|
|
|
2013-10-03 18:49:37 +02:00
|
|
|
|
$self->status_ok($c, entity => $c->stash->{jobset});
|
2013-02-22 14:29:12 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-06-17 12:34:21 -04:00
|
|
|
|
sub jobset_PUT {
|
|
|
|
|
my ($self, $c) = @_;
|
|
|
|
|
|
|
|
|
|
requireProjectOwner($c, $c->stash->{project});
|
2013-02-22 14:29:12 +01:00
|
|
|
|
|
2013-06-17 12:34:21 -04:00
|
|
|
|
if (defined $c->stash->{jobset}) {
|
|
|
|
|
txn_do($c->model('DB')->schema, sub {
|
|
|
|
|
updateJobset($c, $c->stash->{jobset});
|
|
|
|
|
});
|
|
|
|
|
|
2013-10-03 18:49:37 +02:00
|
|
|
|
my $uri = $c->uri_for($self->action_for("jobset"), [$c->stash->{project}->name, $c->stash->{jobset}->name]) . "#tabs-configuration";
|
|
|
|
|
$self->status_ok($c, entity => { redirect => "$uri" });
|
2013-10-03 19:54:22 +02:00
|
|
|
|
|
|
|
|
|
$c->flash->{successMsg} = "The jobset configuration has been updated.";
|
2013-10-03 18:49:37 +02:00
|
|
|
|
}
|
2013-06-17 12:34:21 -04:00
|
|
|
|
|
2013-10-03 18:49:37 +02:00
|
|
|
|
else {
|
2013-06-17 12:34:21 -04:00
|
|
|
|
my $jobset;
|
|
|
|
|
txn_do($c->model('DB')->schema, sub {
|
|
|
|
|
# Note: $jobsetName is validated in updateProject, which will
|
|
|
|
|
# abort the transaction if the name isn't valid.
|
|
|
|
|
$jobset = $c->stash->{project}->jobsets->create(
|
2013-10-03 18:49:37 +02:00
|
|
|
|
{name => ".tmp", nixexprinput => "", nixexprpath => "", emailoverride => ""});
|
2013-06-17 12:34:21 -04:00
|
|
|
|
updateJobset($c, $jobset);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
my $uri = $c->uri_for($self->action_for("jobset"), [$c->stash->{project}->name, $jobset->name]);
|
2013-10-03 18:49:37 +02:00
|
|
|
|
$self->status_created($c,
|
|
|
|
|
location => "$uri",
|
|
|
|
|
entity => { name => $jobset->name, uri => "$uri", redirect => "$uri", type => "jobset" });
|
2013-06-17 12:34:21 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-03 17:54:40 +02:00
|
|
|
|
sub jobset_DELETE {
|
|
|
|
|
my ($self, $c) = @_;
|
|
|
|
|
|
|
|
|
|
requireProjectOwner($c, $c->stash->{project});
|
|
|
|
|
|
|
|
|
|
txn_do($c->model('DB')->schema, sub {
|
2013-10-03 19:42:44 +02:00
|
|
|
|
$c->stash->{jobset}->jobsetevals->delete;
|
|
|
|
|
$c->stash->{jobset}->builds->delete;
|
2013-10-03 17:54:40 +02:00
|
|
|
|
$c->stash->{jobset}->delete;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
my $uri = $c->uri_for($c->controller('Project')->action_for("project"), [$c->stash->{project}->name]);
|
|
|
|
|
$self->status_ok($c, entity => { redirect => "$uri" });
|
2013-10-03 19:54:22 +02:00
|
|
|
|
|
|
|
|
|
$c->flash->{successMsg} = "The jobset has been deleted.";
|
2013-10-03 17:54:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-06-17 12:34:21 -04:00
|
|
|
|
|
|
|
|
|
sub jobs_tab : Chained('jobsetChain') PathPart('jobs-tab') Args(0) {
|
2013-02-22 14:29:12 +01:00
|
|
|
|
my ($self, $c) = @_;
|
|
|
|
|
$c->stash->{template} = 'jobset-jobs-tab.tt';
|
2010-02-09 13:47:20 +00:00
|
|
|
|
|
2013-08-28 09:59:02 +00:00
|
|
|
|
$c->stash->{filter} = $c->request->params->{filter} // "";
|
2013-08-28 12:22:16 +00:00
|
|
|
|
my $filter = "%" . $c->stash->{filter} . "%";
|
2013-08-28 09:59:02 +00:00
|
|
|
|
|
|
|
|
|
my @evals = $c->stash->{jobset}->jobsetevals->search({ hasnewbuilds => 1}, { order_by => "id desc", rows => 20 });
|
|
|
|
|
|
|
|
|
|
my $evals = {};
|
|
|
|
|
my %jobs;
|
|
|
|
|
my $nrBuilds = 0;
|
|
|
|
|
|
|
|
|
|
foreach my $eval (@evals) {
|
|
|
|
|
my @builds = $eval->builds->search(
|
2013-08-28 12:22:16 +00:00
|
|
|
|
{ job => { ilike => $filter } },
|
2013-08-28 09:59:02 +00:00
|
|
|
|
{ columns => ['id', 'job', 'finished', 'buildstatus'] });
|
2013-09-21 14:47:52 +00:00
|
|
|
|
foreach my $b (@builds) {
|
|
|
|
|
my $jobName = $b->get_column('job');
|
2015-02-26 13:01:01 +01:00
|
|
|
|
$evals->{$eval->id}->{timestamp} = $eval->timestamp;
|
|
|
|
|
$evals->{$eval->id}->{jobs}->{$jobName} =
|
2013-09-21 14:47:52 +00:00
|
|
|
|
{ id => $b->id, finished => $b->finished, buildstatus => $b->buildstatus };
|
|
|
|
|
$jobs{$jobName} = 1;
|
|
|
|
|
$nrBuilds++;
|
|
|
|
|
}
|
|
|
|
|
last if $nrBuilds >= 10000;
|
2013-08-28 09:59:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-08-28 12:22:16 +00:00
|
|
|
|
if ($c->request->params->{showInactive}) {
|
2013-09-21 14:47:52 +00:00
|
|
|
|
$c->stash->{showInactive} = 1;
|
|
|
|
|
foreach my $job ($c->stash->{jobset}->jobs->search({ name => { ilike => $filter } })) {
|
|
|
|
|
next if defined $jobs{$job->name};
|
|
|
|
|
$c->stash->{inactiveJobs}->{$job->name} = $jobs{$job->name} = 1;
|
|
|
|
|
}
|
2013-08-28 12:22:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-08-28 09:59:02 +00:00
|
|
|
|
$c->stash->{evals} = $evals;
|
2013-08-28 11:10:40 +00:00
|
|
|
|
my @jobs = sort (keys %jobs);
|
|
|
|
|
$c->stash->{nrJobs} = scalar @jobs;
|
|
|
|
|
splice @jobs, 250 if $c->stash->{filter} eq "";
|
|
|
|
|
$c->stash->{jobs} = [@jobs];
|
2013-08-28 09:59:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-03-13 15:23:08 +00:00
|
|
|
|
# Hydra::Base::Controller::ListBuilds needs this.
|
2013-06-17 12:34:21 -04:00
|
|
|
|
sub get_builds : Chained('jobsetChain') PathPart('') CaptureArgs(0) {
|
2009-03-13 15:23:08 +00:00
|
|
|
|
my ($self, $c) = @_;
|
2009-03-13 17:32:08 +00:00
|
|
|
|
$c->stash->{allBuilds} = $c->stash->{jobset}->builds;
|
2009-04-03 15:37:21 +00:00
|
|
|
|
$c->stash->{latestSucceeded} = $c->model('DB')->resultset('LatestSucceededForJobset')
|
|
|
|
|
->search({}, {bind => [$c->stash->{project}->name, $c->stash->{jobset}->name]});
|
2009-03-13 15:23:08 +00:00
|
|
|
|
$c->stash->{channelBaseName} =
|
2009-03-13 15:41:19 +00:00
|
|
|
|
$c->stash->{project}->name . "-" . $c->stash->{jobset}->name;
|
2009-03-13 15:23:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-06-17 12:34:21 -04:00
|
|
|
|
sub edit : Chained('jobsetChain') PathPart Args(0) {
|
2009-04-02 16:15:57 +00:00
|
|
|
|
my ($self, $c) = @_;
|
2011-05-16 08:03:06 +00:00
|
|
|
|
|
2009-04-02 16:15:57 +00:00
|
|
|
|
requireProjectOwner($c, $c->stash->{project});
|
|
|
|
|
|
2013-02-21 02:33:57 +01:00
|
|
|
|
$c->stash->{template} = 'edit-jobset.tt';
|
2015-07-14 07:39:29 +00:00
|
|
|
|
$c->stash->{edit} = !defined $c->stash->{params}->{cloneJobset};
|
2015-07-06 15:17:35 +02:00
|
|
|
|
$c->stash->{cloneJobset} = defined $c->stash->{params}->{cloneJobset};
|
2013-09-21 14:47:52 +00:00
|
|
|
|
$c->stash->{totalShares} = getTotalShares($c->model('DB')->schema);
|
2009-04-02 16:15:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-10-26 15:39:14 +00:00
|
|
|
|
sub nixExprPathFromParams {
|
|
|
|
|
my ($c) = @_;
|
2011-05-16 08:03:06 +00:00
|
|
|
|
|
2009-04-02 16:15:57 +00:00
|
|
|
|
# The Nix expression path must be relative and can't contain ".." elements.
|
2013-06-17 12:34:21 -04:00
|
|
|
|
my $nixExprPath = trim $c->stash->{params}->{"nixexprpath"};
|
2013-10-03 18:49:37 +02:00
|
|
|
|
error($c, "Invalid Nix expression path ‘$nixExprPath’.") if $nixExprPath !~ /^$relPathRE$/;
|
2009-04-02 16:15:57 +00:00
|
|
|
|
|
2013-06-17 12:34:21 -04:00
|
|
|
|
my $nixExprInput = trim $c->stash->{params}->{"nixexprinput"};
|
2013-10-03 18:49:37 +02:00
|
|
|
|
error($c, "Invalid Nix expression input name ‘$nixExprInput’.") unless $nixExprInput =~ /^[[:alpha:]][\w-]*$/;
|
2009-04-02 16:15:57 +00:00
|
|
|
|
|
2009-10-26 15:39:14 +00:00
|
|
|
|
return ($nixExprPath, $nixExprInput);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sub checkInputValue {
|
2013-11-11 21:17:22 +00:00
|
|
|
|
my ($c, $name, $type, $value) = @_;
|
2014-08-13 17:25:08 +02:00
|
|
|
|
$value = trim $value unless $type eq "string";
|
2013-11-11 21:36:26 +00:00
|
|
|
|
|
2013-11-11 21:17:22 +00:00
|
|
|
|
error($c, "The value ‘$value’ of input ‘$name’ is not a Boolean (‘true’ or ‘false’).") if
|
2009-10-26 15:39:14 +00:00
|
|
|
|
$type eq "boolean" && !($value eq "true" || $value eq "false");
|
2013-11-11 21:36:26 +00:00
|
|
|
|
|
2013-11-11 21:17:22 +00:00
|
|
|
|
error($c, "The value ‘$value’ of input ‘$name’ does not specify a Hydra evaluation. "
|
|
|
|
|
. "It should be either the number of a specific evaluation, the name of "
|
|
|
|
|
. "a jobset (given as <project>:<jobset>), or the name of a job (<project>:<jobset>:<job>).")
|
|
|
|
|
if $type eq "eval" && $value !~ /^\d+$/
|
|
|
|
|
&& $value !~ /^$projectNameRE:$jobsetNameRE$/
|
|
|
|
|
&& $value !~ /^$projectNameRE:$jobsetNameRE:$jobNameRE$/;
|
2013-11-11 21:36:26 +00:00
|
|
|
|
|
2009-10-26 15:39:14 +00:00
|
|
|
|
return $value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sub updateJobset {
|
|
|
|
|
my ($c, $jobset) = @_;
|
|
|
|
|
|
2014-04-23 23:12:00 +02:00
|
|
|
|
my $oldName = $jobset->name;
|
2013-10-03 18:49:37 +02:00
|
|
|
|
my $jobsetName = $c->stash->{params}->{name};
|
|
|
|
|
error($c, "Invalid jobset identifier ‘$jobsetName’.") if $jobsetName !~ /^$jobsetNameRE$/;
|
|
|
|
|
|
|
|
|
|
error($c, "Cannot rename jobset to ‘$jobsetName’ since that identifier is already taken.")
|
2014-04-23 23:12:00 +02:00
|
|
|
|
if $jobsetName ne $oldName && defined $c->stash->{project}->jobsets->find({ name => $jobsetName });
|
2009-10-26 15:39:14 +00:00
|
|
|
|
|
2012-08-16 19:07:04 +02:00
|
|
|
|
# When the expression is in a .scm file, assume it's a Guile + Guix
|
|
|
|
|
# build expression.
|
|
|
|
|
my $exprType =
|
2013-06-17 12:34:21 -04:00
|
|
|
|
$c->stash->{params}->{"nixexprpath"} =~ /.scm$/ ? "guile" : "nix";
|
2012-08-16 19:07:04 +02:00
|
|
|
|
|
2009-10-26 15:39:14 +00:00
|
|
|
|
my ($nixExprPath, $nixExprInput) = nixExprPathFromParams $c;
|
|
|
|
|
|
2013-10-11 12:01:52 +02:00
|
|
|
|
my $enabled = int($c->stash->{params}->{enabled});
|
|
|
|
|
die if $enabled < 0 || $enabled > 2;
|
2013-09-18 11:25:52 +02:00
|
|
|
|
|
2015-08-12 15:36:55 +02:00
|
|
|
|
my $shares = int($c->stash->{params}->{schedulingshares} // 1);
|
|
|
|
|
error($c, "The number of scheduling shares must be positive.") if $shares <= 0;
|
|
|
|
|
|
2009-04-02 16:15:57 +00:00
|
|
|
|
$jobset->update(
|
|
|
|
|
{ name => $jobsetName
|
2013-06-17 12:34:21 -04:00
|
|
|
|
, description => trim($c->stash->{params}->{"description"})
|
2009-04-02 16:15:57 +00:00
|
|
|
|
, nixexprpath => $nixExprPath
|
|
|
|
|
, nixexprinput => $nixExprInput
|
2013-10-11 12:01:52 +02:00
|
|
|
|
, enabled => $enabled
|
2013-06-17 12:34:21 -04:00
|
|
|
|
, enableemail => defined $c->stash->{params}->{enableemail} ? 1 : 0
|
|
|
|
|
, emailoverride => trim($c->stash->{params}->{emailoverride}) || ""
|
|
|
|
|
, hidden => defined $c->stash->{params}->{visible} ? 0 : 1
|
2013-09-18 11:27:37 +02:00
|
|
|
|
, keepnr => int(trim($c->stash->{params}->{keepnr}))
|
2013-06-17 12:34:21 -04:00
|
|
|
|
, checkinterval => int(trim($c->stash->{params}->{checkinterval}))
|
2013-09-18 11:25:52 +02:00
|
|
|
|
, triggertime => $enabled ? $jobset->triggertime // time() : undef
|
2015-08-12 15:36:55 +02:00
|
|
|
|
, schedulingshares => $shares
|
2009-04-02 16:15:57 +00:00
|
|
|
|
});
|
|
|
|
|
|
2014-04-23 23:12:00 +02:00
|
|
|
|
$jobset->project->jobsetrenames->search({ from_ => $jobsetName })->delete;
|
|
|
|
|
$jobset->project->jobsetrenames->create({ from_ => $oldName, to_ => $jobsetName })
|
2014-04-30 09:26:53 +02:00
|
|
|
|
if $oldName ne ".tmp" && $jobsetName ne $oldName;
|
2014-04-23 23:12:00 +02:00
|
|
|
|
|
2013-10-03 17:26:17 +00:00
|
|
|
|
# Set the inputs of this jobset.
|
|
|
|
|
$jobset->jobsetinputs->delete;
|
2009-04-02 16:15:57 +00:00
|
|
|
|
|
2013-10-24 13:00:41 -04:00
|
|
|
|
foreach my $name (keys %{$c->stash->{params}->{inputs}}) {
|
|
|
|
|
my $inputData = $c->stash->{params}->{inputs}->{$name};
|
|
|
|
|
my $type = $inputData->{type};
|
2014-09-25 16:43:17 +02:00
|
|
|
|
my $value = $inputData->{value};
|
2013-10-24 13:00:41 -04:00
|
|
|
|
my $emailresponsible = defined $inputData->{emailresponsible} ? 1 : 0;
|
2009-04-02 16:15:57 +00:00
|
|
|
|
|
2013-10-03 17:26:17 +00:00
|
|
|
|
error($c, "Invalid input name ‘$name’.") unless $name =~ /^[[:alpha:]][\w-]*$/;
|
|
|
|
|
error($c, "Invalid input type ‘$type’.") unless defined $c->stash->{inputTypes}->{$type};
|
2013-07-29 17:42:49 -04:00
|
|
|
|
|
2014-09-25 16:43:17 +02:00
|
|
|
|
my $input = $jobset->jobsetinputs->create(
|
|
|
|
|
{ name => $name,
|
|
|
|
|
type => $type,
|
|
|
|
|
emailresponsible => $emailresponsible
|
2013-10-07 10:46:10 -04:00
|
|
|
|
});
|
2011-05-16 08:03:06 +00:00
|
|
|
|
|
2014-09-25 16:43:17 +02:00
|
|
|
|
$value = checkInputValue($c, $name, $type, $value);
|
|
|
|
|
$input->jobsetinputalts->create({altnr => 0, value => $value});
|
2009-04-02 16:15:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-06-17 12:34:21 -04:00
|
|
|
|
sub clone : Chained('jobsetChain') PathPart('clone') Args(0) {
|
2010-04-23 11:20:40 +00:00
|
|
|
|
my ($self, $c) = @_;
|
|
|
|
|
|
2013-10-03 17:26:17 +00:00
|
|
|
|
requireProjectOwner($c, $c->stash->{project});
|
2011-05-16 08:03:06 +00:00
|
|
|
|
|
2013-10-03 17:26:17 +00:00
|
|
|
|
$c->stash->{template} = 'edit-jobset.tt';
|
2015-07-06 15:17:35 +02:00
|
|
|
|
$c->stash->{cloneJobset} = 1;
|
2013-10-03 17:26:17 +00:00
|
|
|
|
$c->stash->{totalShares} = getTotalShares($c->model('DB')->schema);
|
2010-04-23 11:20:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-06-17 12:34:21 -04:00
|
|
|
|
sub evals :Chained('jobsetChain') :PathPart('evals') :Args(0) :ActionClass('REST') { }
|
|
|
|
|
|
|
|
|
|
sub evals_GET {
|
2012-04-02 16:11:22 +02:00
|
|
|
|
my ($self, $c) = @_;
|
|
|
|
|
|
2013-02-21 17:27:17 +01:00
|
|
|
|
$c->stash->{template} = 'evals.tt';
|
2012-04-02 16:11:22 +02:00
|
|
|
|
|
|
|
|
|
my $page = int($c->req->param('page') || "1") || 1;
|
|
|
|
|
|
|
|
|
|
my $resultsPerPage = 20;
|
|
|
|
|
|
2013-02-21 17:27:17 +01:00
|
|
|
|
my $evals = $c->stash->{jobset}->jobsetevals;
|
|
|
|
|
|
2012-04-02 16:11:22 +02:00
|
|
|
|
$c->stash->{page} = $page;
|
|
|
|
|
$c->stash->{resultsPerPage} = $resultsPerPage;
|
2013-02-21 17:27:17 +01:00
|
|
|
|
$c->stash->{total} = $evals->search({hasnewbuilds => 1})->count;
|
2013-06-17 12:34:21 -04:00
|
|
|
|
my $offset = ($page - 1) * $resultsPerPage;
|
|
|
|
|
$c->stash->{evals} = getEvals($self, $c, $evals, $offset, $resultsPerPage);
|
|
|
|
|
my %entity = (
|
2013-10-29 13:54:11 -04:00
|
|
|
|
evals => [ map { $_->{eval} } @{$c->stash->{evals}} ],
|
2013-06-17 12:34:21 -04:00
|
|
|
|
first => "?page=1",
|
|
|
|
|
last => "?page=" . POSIX::ceil($c->stash->{total}/$resultsPerPage)
|
|
|
|
|
);
|
|
|
|
|
if ($page > 1) {
|
|
|
|
|
$entity{previous} = "?page=" . ($page - 1);
|
|
|
|
|
}
|
|
|
|
|
if ($page < POSIX::ceil($c->stash->{total}/$resultsPerPage)) {
|
|
|
|
|
$entity{next} = "?page=" . ($page + 1);
|
|
|
|
|
}
|
|
|
|
|
$self->status_ok(
|
|
|
|
|
$c,
|
|
|
|
|
entity => \%entity
|
|
|
|
|
);
|
2012-04-02 16:11:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-04-23 11:20:40 +00:00
|
|
|
|
|
2012-04-03 01:30:54 +02:00
|
|
|
|
# Redirect to the latest finished evaluation of this jobset.
|
2013-06-17 12:34:21 -04:00
|
|
|
|
sub latest_eval : Chained('jobsetChain') PathPart('latest-eval') {
|
2012-04-03 01:30:54 +02:00
|
|
|
|
my ($self, $c, @args) = @_;
|
2013-11-11 21:17:22 +00:00
|
|
|
|
my $eval = getLatestFinishedEval($c->stash->{jobset})
|
2012-04-03 11:28:59 +02:00
|
|
|
|
or notFound($c, "No evaluation found.");
|
2012-04-04 12:56:49 +02:00
|
|
|
|
$c->res->redirect($c->uri_for($c->controller('JobsetEval')->action_for("view"), [$eval->id], @args, $c->req->params));
|
2012-04-03 01:30:54 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-03-13 15:23:08 +00:00
|
|
|
|
1;
|