forked from lix-project/hydra
* Add some DB indices to make the /releases page much faster.
* Reduce the number of DB queries for the /all and /jobstatus pages. * Show the Hydra version number.
This commit is contained in:
parent
0da0384753
commit
12c1d90135
|
@ -105,7 +105,8 @@ let
|
|||
wrapProgram $i \
|
||||
--prefix PERL5LIB ':' $out/libexec/hydra/lib:$PERL5LIB \
|
||||
--set PATH $out/bin:$hydraPath \
|
||||
--set HYDRA_HOME $out/libexec/hydra
|
||||
--set HYDRA_HOME $out/libexec/hydra \
|
||||
--set HYDRA_RELEASE ${tarball.version}
|
||||
done
|
||||
|
||||
ensureDir $out/share/doc/hydra/manual
|
||||
|
|
|
@ -34,7 +34,13 @@ sub all : Chained('get_builds') PathPart {
|
|||
$c->stash->{totalBuilds} = $nrBuilds;
|
||||
|
||||
$c->stash->{builds} = [$c->stash->{allBuilds}->search(
|
||||
{finished => 1}, {order_by => "timestamp DESC", rows => $resultsPerPage, page => $page})];
|
||||
{ finished => 1 },
|
||||
{ join => 'resultInfo'
|
||||
, '+select' => ["resultInfo.buildstatus", "resultInfo.releasename"]
|
||||
, '+as' => ["buildstatus", "releasename"]
|
||||
, order_by => "timestamp DESC"
|
||||
, rows => $resultsPerPage
|
||||
, page => $page })];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ sub begin :Private {
|
|||
my ($self, $c) = @_;
|
||||
$c->stash->{projects} = [$c->model('DB::Projects')->search({}, {order_by => 'displayname'})];
|
||||
$c->stash->{curUri} = $c->request->uri;
|
||||
$c->stash->{version} = $ENV{"HYDRA_RELEASE"} || "<devel>";
|
||||
}
|
||||
|
||||
|
||||
|
@ -78,11 +79,11 @@ sub getReleaseSet {
|
|||
my ($c, $projectName, $releaseSetName) = @_;
|
||||
|
||||
my $project = $c->model('DB::Projects')->find($projectName);
|
||||
die "Project $projectName doesn't exist." if !defined $project;
|
||||
notFound($c, "Project $projectName doesn't exist.") if !defined $project;
|
||||
$c->stash->{project} = $project;
|
||||
|
||||
(my $releaseSet) = $c->model('DB::ReleaseSets')->find($projectName, $releaseSetName);
|
||||
die "Release set $releaseSetName doesn't exist." if !defined $releaseSet;
|
||||
notFound($c, "Release set $releaseSetName doesn't exist.") if !defined $releaseSet;
|
||||
$c->stash->{releaseSet} = $releaseSet;
|
||||
|
||||
(my $primaryJob) = $releaseSet->releasesetjobs->search({isprimary => 1});
|
||||
|
@ -101,7 +102,8 @@ sub updateReleaseSet {
|
|||
my ($c, $releaseSet) = @_;
|
||||
|
||||
my $releaseSetName = trim $c->request->params->{name};
|
||||
die "Invalid release set name: $releaseSetName" unless $releaseSetName =~ /^[[:alpha:]][\w\-]*$/;
|
||||
error($c, "Invalid release set name: $releaseSetName")
|
||||
unless $releaseSetName =~ /^[[:alpha:]][\w\-]*$/;
|
||||
|
||||
$releaseSet->update(
|
||||
{ name => $releaseSetName
|
||||
|
@ -137,7 +139,8 @@ sub updateReleaseSet {
|
|||
});
|
||||
}
|
||||
|
||||
die "There must be one primary job." if $releaseSet->releasesetjobs->search({isprimary => 1})->count != 1;
|
||||
error($c, "There must be one primary job.")
|
||||
if $releaseSet->releasesetjobs->search({isprimary => 1})->count != 1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -184,7 +187,7 @@ sub create_releaseset :Local {
|
|||
my ($self, $c, $projectName, $subcommand) = @_;
|
||||
|
||||
my $project = $c->model('DB::Projects')->find($projectName);
|
||||
die "Project $projectName doesn't exist." if !defined $project;
|
||||
error($c, "Project $projectName doesn't exist.") if !defined $project;
|
||||
$c->stash->{project} = $project;
|
||||
|
||||
requireProjectOwner($c, $project);
|
||||
|
@ -222,8 +225,10 @@ sub release :Local {
|
|||
# Note: we don't actually check whether $releaseId is a primary
|
||||
# build, but who cares?
|
||||
my $primaryBuild = $project->builds->find($releaseId,
|
||||
{ join => 'resultInfo', '+select' => ["resultInfo.releasename"], '+as' => ["releasename"] });
|
||||
error($c, "Release $releaseId doesn't exist.") if !defined $primaryBuild;
|
||||
{ join => 'resultInfo',
|
||||
, '+select' => ["resultInfo.releasename", "resultInfo.buildstatus"]
|
||||
, '+as' => ["releasename", "buildstatus"] })
|
||||
or error($c, "Release $releaseId doesn't exist.");
|
||||
|
||||
$c->stash->{release} = getRelease($primaryBuild, $jobs);
|
||||
}
|
||||
|
|
|
@ -55,7 +55,10 @@ sub getLatestBuilds {
|
|||
foreach my $system ($job->builds->search({}, {select => ['system'], distinct => 1})) {
|
||||
my ($build) = $job->builds->search(
|
||||
{ finished => 1, system => $system->system, %$extraAttrs },
|
||||
{ join => 'resultInfo', order_by => 'timestamp DESC', rows => 1 });
|
||||
{ join => 'resultInfo', order_by => 'timestamp DESC', rows => 1
|
||||
, '+select' => ["resultInfo.releasename", "resultInfo.buildstatus"]
|
||||
, '+as' => ["releasename", "buildstatus"]
|
||||
});
|
||||
push @res, $build if defined $build;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,7 +130,8 @@ sub getPrimaryBuildsForReleaseSet {
|
|||
my @primaryBuilds = $project->builds->search(
|
||||
{ jobset => $primaryJob->get_column('jobset'), job => $primaryJob->get_column('job'), finished => 1 },
|
||||
{ join => 'resultInfo', order_by => "timestamp DESC"
|
||||
, '+select' => ["resultInfo.releasename"], '+as' => ["releasename"]
|
||||
, '+select' => ["resultInfo.releasename", "resultInfo.buildstatus"]
|
||||
, '+as' => ["releasename", "buildstatus"]
|
||||
, where => \ attrsToSQL($primaryJob->attrs, "me.id")
|
||||
});
|
||||
return @primaryBuilds;
|
||||
|
@ -158,17 +159,19 @@ sub getRelease {
|
|||
# as input. If there are multiple, prefer successful
|
||||
# ones, and then oldest. !!! order_by buildstatus is hacky
|
||||
($thisBuild) = $primaryBuild->dependentBuilds->search(
|
||||
{ jobset => $job->get_column('jobset'), job => $job->get_column('job'), finished => 1 },
|
||||
{ project => $job->get_column('project'), jobset => $job->get_column('jobset')
|
||||
, job => $job->get_column('job'), finished => 1 },
|
||||
{ join => 'resultInfo', rows => 1
|
||||
, order_by => ["buildstatus", "timestamp"]
|
||||
, where => \ attrsToSQL($job->attrs, "build.id")
|
||||
, '+select' => ["resultInfo.buildstatus"], '+as' => ["buildstatus"]
|
||||
});
|
||||
}
|
||||
|
||||
if ($job->mayfail != 1) {
|
||||
if (!defined $thisBuild) {
|
||||
$status = 2 if $status == 0; # = unfinished
|
||||
} elsif ($thisBuild->resultInfo->buildstatus != 0) {
|
||||
} elsif ($thisBuild->get_column('buildstatus') != 0) {
|
||||
$status = 1; # = failed
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@
|
|||
onclick="window.location = '[% c.uri_for('/build' build.id) %]'">
|
||||
[% IF !hideResultInfo %]
|
||||
<td>
|
||||
[% IF build.resultInfo.buildstatus == 0 %]
|
||||
[% IF build.get_column('buildstatus') == 0 %]
|
||||
<img src="/static/images/success.gif" alt="Succeeded" />
|
||||
[% ELSE %]
|
||||
<img src="/static/images/failure.gif" alt="Failed" />
|
||||
|
@ -94,7 +94,7 @@
|
|||
<td>
|
||||
[% INCLUDE renderFullJobNameOfBuild %]
|
||||
</td>
|
||||
<td>[% build.resultInfo.releasename ? build.resultInfo.releasename : build.nixname %]</td>
|
||||
<td>[% build.get_column('releasename') ? build.get_column('releasename') : build.nixname %]</td>
|
||||
<td><tt>[% build.system %]</tt></td>
|
||||
<td>[% date.format(build.timestamp, '%Y-%m-%d %H:%M:%S') %]</td>
|
||||
<td>[% build.description %]</td>
|
||||
|
|
|
@ -146,7 +146,8 @@
|
|||
[% content %]
|
||||
<div id="footer">
|
||||
<hr />
|
||||
Generated on [% INCLUDE renderDateTime %].
|
||||
<em>Hydra [% HTML.escape(version) %].</em>
|
||||
Page generated on [% INCLUDE renderDateTime %].
|
||||
[% IF c.user_exists %]
|
||||
You are logged in as <tt>[% c.user.username %]</tt>.
|
||||
[% END %]
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
<td class="centered">
|
||||
[% IF job.build %]
|
||||
<a href="[% c.uri_for('/build' job.build.id) %]">
|
||||
[% IF job.build.resultInfo.buildstatus == 0 %]
|
||||
[% IF job.build.get_column('buildstatus') == 0 %]
|
||||
<img src="/static/images/success.gif" />
|
||||
[% ELSE %]
|
||||
<img src="/static/images/failure.gif" />
|
||||
|
|
|
@ -401,3 +401,8 @@ create table ReleaseSetJobs (
|
|||
foreign key (project, release_) references ReleaseSets(project, name) on delete cascade -- ignored by sqlite
|
||||
foreign key (project, jobset) references Jobsets(project, name) on delete restrict -- ignored by sqlite
|
||||
);
|
||||
|
||||
|
||||
-- Some indices.
|
||||
create index IndexBuildInputsByBuild on BuildInputs(build);
|
||||
create index IndexBuildInputsByDependency on BuildInputs(dependency);
|
||||
|
|
Loading…
Reference in a new issue