forked from lix-project/hydra
* Speed up the jobset index page. Especially the query to get the
inactive jobs was quite slow. * "IndexBy" -> "IndexOn".
This commit is contained in:
parent
4abdf86bd4
commit
59e4f65298
|
@ -27,16 +27,30 @@ sub jobsetIndex {
|
||||||
|
|
||||||
#getBuildStats($c, scalar $c->stash->{jobset}->builds);
|
#getBuildStats($c, scalar $c->stash->{jobset}->builds);
|
||||||
|
|
||||||
$c->stash->{activeJobs} = [
|
my $projectName = $c->stash->{project}->name;
|
||||||
$c->stash->{jobset}->builds->search(
|
my $jobsetName = $c->stash->{jobset}->name;
|
||||||
{isCurrent => 1},
|
|
||||||
{select => ["job"], order_by => ["job"], distinct => 1}
|
# Get the active / inactive jobs in this jobset.
|
||||||
)];
|
my @jobs = $c->stash->{jobset}->jobs->search(
|
||||||
$c->stash->{inactiveJobs} = [
|
{ },
|
||||||
$c->stash->{jobset}->builds->search(
|
{ select => [
|
||||||
{},
|
"name",
|
||||||
{select => ["job"], order_by => ["job"], group_by => ["job"], having => { 'sum(isCurrent)' => 0 }}
|
\("exists (select 1 from builds where project = '$projectName' and jobset = '$jobsetName' and job = me.name and isCurrent = 1) as active")
|
||||||
)];
|
]
|
||||||
|
, as => ["name", "active"]
|
||||||
|
, order_by => ["name"] });
|
||||||
|
|
||||||
|
$c->stash->{activeJobs} = [];
|
||||||
|
$c->stash->{inactiveJobs} = [];
|
||||||
|
foreach my $job (@jobs) {
|
||||||
|
print STDERR $job->get_column('active'), "\n";
|
||||||
|
if ($job->get_column('active')) {
|
||||||
|
push @{$c->stash->{activeJobs}}, $job->name;
|
||||||
|
} else {
|
||||||
|
push @{$c->stash->{inactiveJobs}}, $job->name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$c->stash->{systems} = [$c->stash->{jobset}->builds->search({iscurrent => 1}, {select => ["system"], distinct => 1})];
|
$c->stash->{systems} = [$c->stash->{jobset}->builds->search({iscurrent => 1}, {select => ["system"], distinct => 1})];
|
||||||
|
|
||||||
# status per system
|
# status per system
|
||||||
|
@ -46,23 +60,24 @@ sub jobsetIndex {
|
||||||
}
|
}
|
||||||
|
|
||||||
if($forceStatus || scalar(@{$c->stash->{activeJobs}}) <= 20) {
|
if($forceStatus || scalar(@{$c->stash->{activeJobs}}) <= 20) {
|
||||||
my @select = ();
|
my @select = ();
|
||||||
my @as = ();
|
my @as = ();
|
||||||
push(@select, "job"); push(@as, "job");
|
push(@select, "job"); push(@as, "job");
|
||||||
foreach my $system (@systems) {
|
foreach my $system (@systems) {
|
||||||
push(@select, "(SELECT buildstatus FROM BuildResultInfo bri NATURAL JOIN Builds b WHERE b.id = (SELECT MAX(id) FROM Builds t WHERE t.project = me.project AND t.jobset = me.jobset AND t.job = me.job AND t.system = '$system'))");
|
push(@select, "(SELECT buildstatus FROM BuildResultInfo bri NATURAL JOIN Builds b WHERE b.id = (SELECT MAX(id) FROM Builds t WHERE t.project = me.project AND t.jobset = me.jobset AND t.job = me.job AND t.system = '$system'))");
|
||||||
push(@as, $system);
|
push(@as, $system);
|
||||||
push(@select, "(SELECT b.id FROM BuildResultInfo bri NATURAL JOIN Builds b WHERE b.id = (SELECT MAX(id) FROM Builds t WHERE t.project = me.project AND t.jobset = me.jobset AND t.job = me.job AND t.system = '$system'))");
|
push(@select, "(SELECT b.id FROM BuildResultInfo bri NATURAL JOIN Builds b WHERE b.id = (SELECT MAX(id) FROM Builds t WHERE t.project = me.project AND t.jobset = me.jobset AND t.job = me.job AND t.system = '$system'))");
|
||||||
push(@as, $system."-build");
|
push(@as, $system."-build");
|
||||||
}
|
}
|
||||||
$c->stash->{activeJobsStatus} = [$c->model('DB')->resultset('ActiveJobsForJobset')
|
$c->stash->{activeJobsStatus} =
|
||||||
->search( {}
|
[ $c->model('DB')->resultset('ActiveJobsForJobset')->search(
|
||||||
, { bind => [$c->stash->{project}->name, $c->stash->{jobset}->name]
|
{},
|
||||||
, select => \@select
|
{ bind => [$c->stash->{project}->name, $c->stash->{jobset}->name]
|
||||||
, as => \@as
|
, select => \@select
|
||||||
, order_by => ["job"]
|
, as => \@as
|
||||||
})];
|
, order_by => ["job"]
|
||||||
}
|
})];
|
||||||
|
}
|
||||||
|
|
||||||
# last builds for jobset
|
# last builds for jobset
|
||||||
my $tmp = $c->stash->{jobset}->builds;
|
my $tmp = $c->stash->{jobset}->builds;
|
||||||
|
|
|
@ -238,15 +238,15 @@
|
||||||
|
|
||||||
<blockquote>
|
<blockquote>
|
||||||
[% IF activeJobs.size == 0 %]<em>(none)</em>[% END %]
|
[% IF activeJobs.size == 0 %]<em>(none)</em>[% END %]
|
||||||
[% FOREACH j IN activeJobs %] [% INCLUDE renderJobName project=project.name jobset=jobset.name job=j.get_column('job') %] [% END %]
|
[% FOREACH j IN activeJobs %] [% INCLUDE renderJobName project=project.name jobset=jobset.name job=j %] [% END %]
|
||||||
</blockquote>
|
</blockquote>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>This jobset used to contain the following [% inactiveJobs.size %] jobs:
|
<p>This jobset used to contain the following [% inactiveJobs.size %] jobs:
|
||||||
|
|
||||||
<blockquote>
|
<blockquote>
|
||||||
[% IF inactiveJobs.size == 0 %]<em>(none)</em>[% END %]
|
[% IF inactiveJobs.size == 0 %]<em>(none)</em>[% END %]
|
||||||
[% FOREACH j IN inactiveJobs %] [% INCLUDE renderJobName project=project.name jobset=jobset.name job=j.get_column('job') %] [% END %]
|
[% FOREACH j IN inactiveJobs %] [% INCLUDE renderJobName project=project.name jobset=jobset.name job=j %] [% END %]
|
||||||
</blockquote>
|
</blockquote>
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -422,20 +422,22 @@ create table JobsetInputHashes (
|
||||||
|
|
||||||
|
|
||||||
-- Some indices.
|
-- Some indices.
|
||||||
create index IndexBuildInputsByBuild on BuildInputs(build);
|
create index IndexBuildInputsOnBuild on BuildInputs(build);
|
||||||
create index IndexBuildInputsByDependency on BuildInputs(dependency);
|
create index IndexBuildInputsOnDependency on BuildInputs(dependency);
|
||||||
create index IndexBuildsByTimestamp on Builds(timestamp);
|
create index IndexBuildProducstOnBuildAndType on BuildProducts(build, type);
|
||||||
create index IndexBuildsByIsCurrent on Builds(isCurrent);
|
create index IndexBuildProductsOnBuild on BuildProducts(build);
|
||||||
create index IndexBuildsByFinished on Builds(finished);
|
|
||||||
create index IndexBuildsByProject on Builds(project);
|
|
||||||
create index IndexBuildsByJobset on Builds(project, jobset);
|
|
||||||
create index IndexBuildsByJob on Builds(project, jobset, job);
|
|
||||||
create index IndexBuildsByJobAndSystem on Builds(project, jobset, job, system);
|
|
||||||
create index IndexBuildResultInfo on BuildResultInfo(id); -- primary key index, not created automatically by PostgreSQL
|
create index IndexBuildResultInfo on BuildResultInfo(id); -- primary key index, not created automatically by PostgreSQL
|
||||||
create index IndexBuildSchedulingInfoByBuild on BuildSchedulingInfo(id); -- idem
|
create index IndexBuildSchedulingInfoOnBuild on BuildSchedulingInfo(id); -- idem
|
||||||
create index IndexBuildProductsByBuild on BuildProducts(build);
|
create index IndexBuildStepsOnBuild on BuildSteps(build);
|
||||||
create index IndexBuildProducstByBuildAndType on BuildProducts(build, type);
|
create index IndexBuildsOnFinished on Builds(finished);
|
||||||
create index IndexBuildStepsByBuild on BuildSteps(build);
|
create index IndexBuildsOnIsCurrent on Builds(isCurrent);
|
||||||
|
create index IndexBuildsOnJob on Builds(project, jobset, job);
|
||||||
|
create index IndexBuildsOnJobAndIsCurrent on Builds(project, jobset, job, isCurrent);
|
||||||
|
create index IndexBuildsOnJobAndSystem on Builds(project, jobset, job, system);
|
||||||
|
create index IndexBuildsOnJobset on Builds(project, jobset);
|
||||||
|
create index IndexBuildsOnProject on Builds(project);
|
||||||
|
create index IndexBuildsOnTimestamp on Builds(timestamp);
|
||||||
|
create index IndexJobsetAltsOnJobset on JobsetInputAlts(project, jobset);
|
||||||
|
|
||||||
|
|
||||||
#ifdef SQLITE
|
#ifdef SQLITE
|
||||||
|
|
Loading…
Reference in a new issue