forked from lix-project/hydra
* More renaming.
This commit is contained in:
parent
321027b262
commit
2cf42489e2
|
@ -95,8 +95,8 @@ sub view_view : Chained('view') PathPart('') Args(0) {
|
||||||
my $page = int($c->req->param('page')) || 1;
|
my $page = int($c->req->param('page')) || 1;
|
||||||
|
|
||||||
my @results = ();
|
my @results = ();
|
||||||
push @results, getRelease($_, $c->stash->{jobs}) foreach
|
push @results, getViewResult($_, $c->stash->{jobs}) foreach
|
||||||
getPrimaryBuildsForReleaseSet($c->stash->{project}, $c->stash->{primaryJob}, $page, $resultsPerPage);
|
getPrimaryBuildsForView($c->stash->{project}, $c->stash->{primaryJob}, $page, $resultsPerPage);
|
||||||
|
|
||||||
$c->stash->{baseUri} = $c->uri_for($self->action_for("view_view"), $c->req->captures);
|
$c->stash->{baseUri} = $c->uri_for($self->action_for("view_view"), $c->req->captures);
|
||||||
$c->stash->{results} = [@results];
|
$c->stash->{results} = [@results];
|
||||||
|
@ -138,7 +138,7 @@ sub latest : Chained('view') PathPart('latest') {
|
||||||
|
|
||||||
# Redirect to the latest result in the view in which every build
|
# Redirect to the latest result in the view in which every build
|
||||||
# is successful.
|
# is successful.
|
||||||
my $latest = getLatestSuccessfulRelease(
|
my $latest = getLatestSuccessfulViewResult(
|
||||||
$c->stash->{project}, $c->stash->{primaryJob}, $c->stash->{jobs});
|
$c->stash->{project}, $c->stash->{primaryJob}, $c->stash->{jobs});
|
||||||
error($c, "This view set has no successful results yet.") if !defined $latest;
|
error($c, "This view set has no successful results yet.") if !defined $latest;
|
||||||
$c->res->redirect($c->uri_for($self->action_for("view_view"), $c->req->captures, $latest->id, @args));
|
$c->res->redirect($c->uri_for($self->action_for("view_view"), $c->req->captures, $latest->id, @args));
|
||||||
|
@ -158,7 +158,7 @@ sub result : Chained('view') PathPart('') {
|
||||||
, '+as' => ["releasename", "buildstatus"] })
|
, '+as' => ["releasename", "buildstatus"] })
|
||||||
or error($c, "Build $id doesn't exist.");
|
or error($c, "Build $id doesn't exist.");
|
||||||
|
|
||||||
$c->stash->{result} = getRelease($primaryBuild, $c->stash->{jobs});
|
$c->stash->{result} = getViewResult($primaryBuild, $c->stash->{jobs});
|
||||||
|
|
||||||
# Provide a redirect to the specified job of this view result.
|
# Provide a redirect to the specified job of this view result.
|
||||||
# !!! This isn't uniquely defined if there are multiple jobs with
|
# !!! This isn't uniquely defined if there are multiple jobs with
|
||||||
|
|
|
@ -10,9 +10,9 @@ our @EXPORT = qw(
|
||||||
isValidPath queryPathInfo
|
isValidPath queryPathInfo
|
||||||
getHydraPath getHydraDBPath openHydraDB txn_do
|
getHydraPath getHydraDBPath openHydraDB txn_do
|
||||||
registerRoot getGCRootsDir gcRootFor
|
registerRoot getGCRootsDir gcRootFor
|
||||||
getPrimaryBuildsForReleaseSet
|
getPrimaryBuildsForView
|
||||||
getPrimaryBuildTotal
|
getPrimaryBuildTotal
|
||||||
getRelease getLatestSuccessfulRelease );
|
getViewResult getLatestSuccessfulViewResult );
|
||||||
|
|
||||||
|
|
||||||
sub isValidPath {
|
sub isValidPath {
|
||||||
|
@ -135,7 +135,7 @@ sub attrsToSQL {
|
||||||
my $query = "1 = 1";
|
my $query = "1 = 1";
|
||||||
|
|
||||||
foreach my $attr (@attrs) {
|
foreach my $attr (@attrs) {
|
||||||
$attr =~ /^([\w-]+)=([\w-]*)$/ or die "invalid attribute in release set: $attr";
|
$attr =~ /^([\w-]+)=([\w-]*)$/ or die "invalid attribute in view: $attr";
|
||||||
my $name = $1;
|
my $name = $1;
|
||||||
my $value = $2;
|
my $value = $2;
|
||||||
# !!! Yes, this is horribly injection-prone... (though
|
# !!! Yes, this is horribly injection-prone... (though
|
||||||
|
@ -149,23 +149,25 @@ sub attrsToSQL {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub allPrimaryBuilds {
|
sub allPrimaryBuilds {
|
||||||
my ($project, $primaryJob) = @_;
|
my ($project, $primaryJob) = @_;
|
||||||
my $allPrimaryBuilds = $project->builds->search(
|
my $allPrimaryBuilds = $project->builds->search(
|
||||||
{ jobset => $primaryJob->get_column('jobset'), job => $primaryJob->get_column('job'), finished => 1 },
|
{ jobset => $primaryJob->get_column('jobset'), job => $primaryJob->get_column('job'), finished => 1 },
|
||||||
{ join => 'resultInfo', order_by => "timestamp DESC"
|
{ join => 'resultInfo', order_by => "timestamp DESC"
|
||||||
, '+select' => ["resultInfo.releasename", "resultInfo.buildstatus"]
|
, '+select' => ["resultInfo.releasename", "resultInfo.buildstatus"]
|
||||||
, '+as' => ["releasename", "buildstatus"]
|
, '+as' => ["releasename", "buildstatus"]
|
||||||
, where => \ attrsToSQL($primaryJob->attrs, "me.id")
|
, where => \ attrsToSQL($primaryJob->attrs, "me.id")
|
||||||
});
|
});
|
||||||
return $allPrimaryBuilds;
|
return $allPrimaryBuilds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub getPrimaryBuildTotal {
|
sub getPrimaryBuildTotal {
|
||||||
my ($project, $primaryJob) = @_;
|
my ($project, $primaryJob) = @_;
|
||||||
return scalar(allPrimaryBuilds($project, $primaryJob)) ;
|
return scalar(allPrimaryBuilds($project, $primaryJob));
|
||||||
}
|
}
|
||||||
|
|
||||||
sub getPrimaryBuildsForReleaseSet {
|
|
||||||
|
sub getPrimaryBuildsForView {
|
||||||
my ($project, $primaryJob, $page, $resultsPerPage) = @_;
|
my ($project, $primaryJob, $page, $resultsPerPage) = @_;
|
||||||
$page = (defined $page ? int($page) : 1) || 1;
|
$page = (defined $page ? int($page) : 1) || 1;
|
||||||
$resultsPerPage = (defined $resultsPerPage ? int($resultsPerPage) : 20) || 20;
|
$resultsPerPage = (defined $resultsPerPage ? int($resultsPerPage) : 20) || 20;
|
||||||
|
@ -178,6 +180,7 @@ sub getPrimaryBuildsForReleaseSet {
|
||||||
return @primaryBuilds;
|
return @primaryBuilds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub findLastJobForBuilds {
|
sub findLastJobForBuilds {
|
||||||
my ($builds, $job) = @_;
|
my ($builds, $job) = @_;
|
||||||
my $thisBuild;
|
my $thisBuild;
|
||||||
|
@ -198,6 +201,7 @@ sub findLastJobForBuilds {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub findLastJobForPrimaryBuild {
|
sub findLastJobForPrimaryBuild {
|
||||||
my ($primaryBuild, $job) = @_;
|
my ($primaryBuild, $job) = @_;
|
||||||
my $thisBuild;
|
my $thisBuild;
|
||||||
|
@ -219,14 +223,15 @@ sub findLastJobForPrimaryBuild {
|
||||||
return $thisBuild;
|
return $thisBuild;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub getRelease {
|
|
||||||
|
sub getViewResult {
|
||||||
my ($primaryBuild, $jobs) = @_;
|
my ($primaryBuild, $jobs) = @_;
|
||||||
|
|
||||||
my @jobs = ();
|
my @jobs = ();
|
||||||
|
|
||||||
my $status = 0; # = okay
|
my $status = 0; # = okay
|
||||||
|
|
||||||
# The timestamp of the release 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;
|
||||||
|
|
||||||
|
@ -261,11 +266,11 @@ sub getRelease {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub getLatestSuccessfulRelease {
|
sub getLatestSuccessfulViewResult {
|
||||||
my ($project, $primaryJob, $jobs) = @_;
|
my ($project, $primaryJob, $jobs) = @_;
|
||||||
my $latest;
|
my $latest;
|
||||||
foreach my $build (getPrimaryBuildsForReleaseSet($project, $primaryJob)) {
|
foreach my $build (getPrimaryBuildsForView($project, $primaryJob)) {
|
||||||
return $build if getRelease($build, $jobs)->{status} == 0;
|
return $build if getViewResult($build, $jobs)->{status} == 0;
|
||||||
}
|
}
|
||||||
return undef;
|
return undef;
|
||||||
|
|
||||||
|
|
|
@ -57,20 +57,20 @@ foreach my $project ($db->resultset('Projects')->all) {
|
||||||
keepBuild $_ foreach @recentBuilds;
|
keepBuild $_ foreach @recentBuilds;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Go over all releases in this project.
|
# Go over all views in this project.
|
||||||
|
|
||||||
foreach my $releaseSet ($project->releasesets->all) {
|
foreach my $view ($project->views->all) {
|
||||||
print STDERR "*** looking for builds to keep in release set ", $project->name, ":", $releaseSet->name, "\n";
|
print STDERR "*** looking for builds to keep in view ", $project->name, ":", $view->name, "\n";
|
||||||
|
|
||||||
(my $primaryJob) = $releaseSet->releasesetjobs->search({isprimary => 1});
|
(my $primaryJob) = $view->viewjobs->search({isprimary => 1});
|
||||||
my $jobs = [$releaseSet->releasesetjobs->all];
|
my $jobs = [$view->viewjobs->all];
|
||||||
|
|
||||||
# Keep all builds belonging to the most recent successful release.
|
# Keep all builds belonging to the most recent successful view result.
|
||||||
my $latest = getLatestSuccessfulRelease($project, $primaryJob, $jobs);
|
my $latest = getLatestSuccessfulViewResult($project, $primaryJob, $jobs);
|
||||||
if (defined $latest) {
|
if (defined $latest) {
|
||||||
print STDERR "keeping latest successful release ", $latest->id, " (", $latest->get_column('releasename'), ")\n";
|
print STDERR "keeping latest successful view result ", $latest->id, " (", $latest->get_column('releasename'), ")\n";
|
||||||
my $release = getRelease($latest, $jobs);
|
my $result = getViewResult($latest, $jobs);
|
||||||
keepBuild $_->{build} foreach @{$release->{jobs}};
|
keepBuild $_->{build} foreach @{$result->{jobs}};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue