forked from lix-project/hydra
getPrimaryBuildsForView: Return all view results
Returning only the first 20 results can cause NixOS/Nixpkgs channel generation to fail, if the first 20 view results correspond to evaluations that haven't finished yet. Then URLs like /view/nixos/tested/latest-finished will return 500 rather than the latest finished view.
This commit is contained in:
parent
bfc1b0e76a
commit
591aee0793
|
@ -114,13 +114,9 @@ sub getPrimaryBuildTotal {
|
||||||
|
|
||||||
sub getPrimaryBuildsForView {
|
sub getPrimaryBuildsForView {
|
||||||
my ($project, $primaryJob, $page, $resultsPerPage) = @_;
|
my ($project, $primaryJob, $page, $resultsPerPage) = @_;
|
||||||
$page = (defined $page ? int($page) : 1) || 1;
|
|
||||||
$resultsPerPage = (defined $resultsPerPage ? int($resultsPerPage) : 20) || 20;
|
|
||||||
|
|
||||||
my @primaryBuilds = allPrimaryBuilds($project, $primaryJob)->search( {},
|
my @primaryBuilds = allPrimaryBuilds($project, $primaryJob)->search(
|
||||||
{ rows => $resultsPerPage
|
{}, defined $resultsPerPage ? { rows => $resultsPerPage, page => $page } : {});
|
||||||
, page => $page
|
|
||||||
});
|
|
||||||
|
|
||||||
return @primaryBuilds;
|
return @primaryBuilds;
|
||||||
}
|
}
|
||||||
|
@ -181,7 +177,7 @@ sub jobsetOverview {
|
||||||
|
|
||||||
|
|
||||||
sub getViewResult {
|
sub getViewResult {
|
||||||
my ($primaryBuild, $jobs) = @_;
|
my ($primaryBuild, $jobs, $finished) = @_;
|
||||||
|
|
||||||
my @jobs = ();
|
my @jobs = ();
|
||||||
|
|
||||||
|
@ -194,6 +190,11 @@ sub getViewResult {
|
||||||
my $ev = $primaryBuild->jobsetevalmembers->find({}, { rows => 1, order_by => "eval" });
|
my $ev = $primaryBuild->jobsetevalmembers->find({}, { rows => 1, order_by => "eval" });
|
||||||
$ev = $ev->eval if defined $ev;
|
$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
|
# The timestamp of the view result is the highest timestamp of all
|
||||||
# constitutent builds.
|
# constitutent builds.
|
||||||
my $timestamp = 0;
|
my $timestamp = 0;
|
||||||
|
@ -230,12 +231,9 @@ sub getLatestSuccessfulViewResult {
|
||||||
my ($project, $primaryJob, $jobs, $finished) = @_;
|
my ($project, $primaryJob, $jobs, $finished) = @_;
|
||||||
my $latest;
|
my $latest;
|
||||||
foreach my $build (getPrimaryBuildsForView($project, $primaryJob)) {
|
foreach my $build (getPrimaryBuildsForView($project, $primaryJob)) {
|
||||||
my $result = getViewResult($build, $jobs);
|
my $result = getViewResult($build, $jobs, $finished);
|
||||||
|
next unless defined $result;
|
||||||
next if $result->{status} != 0;
|
next if $result->{status} != 0;
|
||||||
if ($finished) {
|
|
||||||
next unless defined $result->{eval};
|
|
||||||
next if $result->{eval}->builds->search({ finished => 0 })->count > 0;
|
|
||||||
}
|
|
||||||
return $build;
|
return $build;
|
||||||
}
|
}
|
||||||
return undef;
|
return undef;
|
||||||
|
|
Loading…
Reference in a new issue