* 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:
Eelco Dolstra
2009-03-23 13:52:24 +00:00
parent 0da0384753
commit 12c1d90135
9 changed files with 41 additions and 17 deletions

View File

@ -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;
}
}

View File

@ -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
}
}