forked from lix-project/hydra
* In views, support selecting a job that doesn't depend on the
primary job, but is in the same jobset.
This commit is contained in:
parent
3501fa6465
commit
70466156e6
|
@ -92,7 +92,7 @@ sub view_view : Chained('view') PathPart('') Args(0) {
|
||||||
$c->stash->{template} = 'view.tt';
|
$c->stash->{template} = 'view.tt';
|
||||||
|
|
||||||
my $resultsPerPage = 10;
|
my $resultsPerPage = 10;
|
||||||
my $page = int($c->req->param('page')) || 1;
|
my $page = int($c->req->param('page') || "1") || 1;
|
||||||
|
|
||||||
my @results = ();
|
my @results = ();
|
||||||
push @results, getViewResult($_, $c->stash->{jobs}) foreach
|
push @results, getViewResult($_, $c->stash->{jobs}) foreach
|
||||||
|
|
|
@ -157,21 +157,41 @@ sub getPrimaryBuildsForView {
|
||||||
|
|
||||||
|
|
||||||
sub findLastJobForBuilds {
|
sub findLastJobForBuilds {
|
||||||
my ($builds, $job) = @_;
|
my ($ev, $depBuilds, $job) = @_;
|
||||||
my $thisBuild;
|
my $thisBuild;
|
||||||
|
|
||||||
# Find a build of this job that had the primary build
|
my $project = $job->get_column('project');
|
||||||
# as input. If there are multiple, prefer successful
|
my $jobset = $job->get_column('jobset');
|
||||||
# ones, and then oldest. !!! order_by buildstatus is hacky
|
|
||||||
($thisBuild) = $builds->search(
|
# If the job is in the same jobset as the primary build, then
|
||||||
{ project => $job->get_column('project'), jobset => $job->get_column('jobset')
|
# search for a build of the job among the members of the jobset
|
||||||
|
# evaluation ($ev) that produced the primary build.
|
||||||
|
if (defined $ev && $project eq $ev->get_column('project')
|
||||||
|
&& $jobset eq $ev->get_column('jobset'))
|
||||||
|
{
|
||||||
|
$thisBuild = $ev->builds->find(
|
||||||
|
{ job => $job->get_column('job'), finished => 1 },
|
||||||
|
{ join => 'resultInfo', rows => 1
|
||||||
|
, order_by => ["id"]
|
||||||
|
, where => \ attrsToSQL($job->attrs, "build.id")
|
||||||
|
, '+select' => ["resultInfo.buildstatus"], '+as' => ["buildstatus"]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
# As backwards compatibility, find a build of this job that had
|
||||||
|
# the primary build as input. If there are multiple, prefer
|
||||||
|
# successful ones, and then oldest. !!! order_by buildstatus is
|
||||||
|
# hacky
|
||||||
|
$thisBuild = $depBuilds->find(
|
||||||
|
{ project => $project, jobset => $jobset
|
||||||
, job => $job->get_column('job'), finished => 1
|
, job => $job->get_column('job'), finished => 1
|
||||||
},
|
},
|
||||||
{ join => 'resultInfo', rows => 1
|
{ join => 'resultInfo', rows => 1
|
||||||
, order_by => ["buildstatus", "timestamp"]
|
, order_by => ["buildstatus", "timestamp"]
|
||||||
, where => \ attrsToSQL($job->attrs, "build.id")
|
, where => \ attrsToSQL($job->attrs, "build.id")
|
||||||
, '+select' => ["resultInfo.buildstatus"], '+as' => ["buildstatus"]
|
, '+select' => ["resultInfo.buildstatus"], '+as' => ["buildstatus"]
|
||||||
});
|
})
|
||||||
|
unless defined $thisBuild;
|
||||||
|
|
||||||
return $thisBuild;
|
return $thisBuild;
|
||||||
}
|
}
|
||||||
|
@ -184,6 +204,13 @@ sub getViewResult {
|
||||||
|
|
||||||
my $status = 0; # = okay
|
my $status = 0; # = okay
|
||||||
|
|
||||||
|
# Get the jobset evaluation of which the primary build is a
|
||||||
|
# member. If there are multiple, pick the oldest one (i.e. the
|
||||||
|
# lowest id). (Note that for old builds in the database there
|
||||||
|
# might not be a evaluation record, so $ev may be undefined.)
|
||||||
|
my $ev = $primaryBuild->jobsetevalmembers->find({}, { rows => 1, order_by => "eval" });
|
||||||
|
$ev = $ev->eval if defined $ev;
|
||||||
|
|
||||||
# The timestamp of the view result is the highest timestamp of all
|
# The timestamp of the view result is the highest timestamp of all
|
||||||
# constitutent builds.
|
# constitutent builds.
|
||||||
my $timestamp = 0;
|
my $timestamp = 0;
|
||||||
|
@ -191,7 +218,7 @@ sub getViewResult {
|
||||||
foreach my $job (@{$jobs}) {
|
foreach my $job (@{$jobs}) {
|
||||||
my $thisBuild = $job->isprimary
|
my $thisBuild = $job->isprimary
|
||||||
? $primaryBuild
|
? $primaryBuild
|
||||||
: findLastJobForBuilds(scalar $primaryBuild->dependentBuilds, $job);
|
: findLastJobForBuilds($ev, scalar $primaryBuild->dependentBuilds, $job);
|
||||||
|
|
||||||
if (!defined $thisBuild) {
|
if (!defined $thisBuild) {
|
||||||
$status = 2 if $status == 0; # = unfinished
|
$status = 2 if $status == 0; # = unfinished
|
||||||
|
|
|
@ -196,5 +196,13 @@ if ($hydradbi =~ m/^dbi:Pg/) {
|
||||||
__PACKAGE__->sequence('jobsetevals_id_seq');
|
__PACKAGE__->sequence('jobsetevals_id_seq');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__PACKAGE__->has_many(
|
||||||
|
"buildIds",
|
||||||
|
"Hydra::Schema::JobsetEvalMembers",
|
||||||
|
{ "foreign.eval" => "self.id" },
|
||||||
|
);
|
||||||
|
|
||||||
|
__PACKAGE__->many_to_many(builds => 'buildIds', 'build');
|
||||||
|
|
||||||
# You can replace this text with custom content, and it will be preserved on regeneration
|
# You can replace this text with custom content, and it will be preserved on regeneration
|
||||||
1;
|
1;
|
||||||
|
|
Loading…
Reference in a new issue