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2C3K6ADTIREKZQEOVVORQC
AFTXA575C6JTVLVXTYJUKQGPLBO3NFORLO5XDSPHNL44HXLRH4TAC
ZCTGG25SELGUTOYLG72N2I2OF7YQ6B7CIBPCP5ANMDDD4FIQ3YPQC
Y6AHH4THYQA43V77L43YM42DYRPCMDSWLUV4NKWAQYMPL4NTUIPQC
HTL6HIBMRGSX2H2H7KB4MC3H6UQ5C752VC3UHC43SRA7V66PQCRQC
JFZNAYJXKCMXYHGCLTRH7Q6TOFGJ4BT6332GONCWVYRLNMDDG3KAC
4WZQW2N6NJSIKSK7DCOV2YVEG5C45LLUM2FCCZRLISUXUGMBGF6QC
IK53RV4VGOHLCZGQCCIKPB45M3C7M7YMNBOJFBGZJ4LWIZNU4QNQC
IE3SRMWZ4YT6EYKAOG2HH54MXG5TYYBW7OEBHNYJUGW7KILFXX2AC
JLDUSNUOOQNL63BOPXIWZOWFRQ5X35RWG33PJB3J3KMR6QR7TN7QC
6KIJX24R5RRDR2UQMUAWHF3N6V6DKKL5URYSLB7IT4J5C3RO4G2AC
ODNCGFQ5FPKFI624BVMLW7PJ2EFJOR3TY66OCZM42UNNTWBCF2TQC
}
sub allPrimaryBuilds {
my ($project, $primaryJob) = @_;
my $allPrimaryBuilds = $project->builds->search(
{ jobset => $primaryJob->get_column('jobset'), job => $primaryJob->get_column('job'), finished => 1 },
{ order_by => "id DESC"
, where => \ attrsToSQL($primaryJob->attrs, "me.id")
});
return $allPrimaryBuilds;
}
sub getPrimaryBuildTotal {
my ($project, $primaryJob) = @_;
return scalar(allPrimaryBuilds($project, $primaryJob));
sub getPrimaryBuildsForView {
my ($project, $primaryJob, $page, $resultsPerPage) = @_;
my @primaryBuilds = allPrimaryBuilds($project, $primaryJob)->search(
{}, defined $resultsPerPage ? { rows => $resultsPerPage, page => $page } : {});
return @primaryBuilds;
}
sub findLastJobForBuilds {
my ($ev, $depBuilds, $job) = @_;
my $thisBuild;
my $project = $job->get_column('project');
my $jobset = $job->get_column('jobset');
# If the job is in the same jobset as the primary build, then
# 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 },
{ rows => 1
, order_by => ["build.id"]
, where => \ attrsToSQL($job->attrs, "build.id")
});
}
# 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
},
{ rows => 1
, order_by => ["buildstatus", "id"]
, where => \ attrsToSQL($job->attrs, "build.id")
})
unless defined $thisBuild;
return $thisBuild;
}
}
sub getViewResult {
my ($primaryBuild, $jobs, $finished) = @_;
my @jobs = ();
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;
if ($finished) {
return undef unless defined $ev;
return undef if $ev->builds->search({ finished => 0 })->count > 0;
}
# The timestamp of the view result is the highest timestamp of all
# constitutent builds.
my $timestamp = 0;
foreach my $job (@{$jobs}) {
my $thisBuild = $job->isprimary
? $primaryBuild
: findLastJobForBuilds($ev, scalar $primaryBuild->dependentBuilds, $job);
if (!defined $thisBuild) {
$status = 2 if $status == 0; # = unfinished
} elsif ($thisBuild->get_column('buildstatus') != 0) {
$status = 1; # = failed
}
$timestamp = $thisBuild->timestamp
if defined $thisBuild && $thisBuild->timestamp > $timestamp;
push @jobs, { build => $thisBuild, job => $job };
}
return
{ id => $primaryBuild->id
, releasename => $primaryBuild->get_column('releasename')
, jobs => [@jobs]
, status => $status
, timestamp => $timestamp
, eval => $ev
};
}
sub getLatestSuccessfulViewResult {
my ($project, $primaryJob, $jobs, $finished) = @_;
my $latest;
foreach my $build (getPrimaryBuildsForView($project, $primaryJob)) {
my $result = getViewResult($build, $jobs, $finished);
next unless defined $result;
next if $result->{status} != 0;
return $build;
}
return undef;
BLOCK renderViewJobName;
IF job.description; HTML.escape(job.description); ELSE %]<tt>[% job.job %]</tt> ([% job.attrs %])[% END;
END;