inactive jobs was quite slow.
6QRHXIM3XHCDLSIIBEGETDV67V6LTV55QMHC64ZPBMLTAECM5N3QC
ID277UG3B3SXBGZ5U57LXURZTS6WHKAF2F63W5E3QH46KRAXU2ZQC
AKAXJDMWEPMXMUY5R53AOVYAGSV42ZZ53URH7HAPUB5KZZV56TPAC
TJPIS3UPRE4ZIPXGRO7B4KOPR7P6UDYWUKCNY6UHJQEQDXWS4XVAC
ODNCGFQ5FPKFI624BVMLW7PJ2EFJOR3TY66OCZM42UNNTWBCF2TQC
3HZY24CX4U2TO74HOY4YX3LBJIYF4DLXHCIY7J2RASAC4COMSMZAC
SFUSIKUYLJ6KO5UGPIGXELXQPR5BK2PSPIWVFNPKM42BSSQHYAUQC
ZI535LI6PJMKSOBJE33B3RRZ5S2JVTR3XPUDTSXJW6BZNTAHS3GQC
T2232OBSNVDGHY46RY5BBB2IET5LV5OLKSSBDYUF7KAEDBUOTC7QC
N22GPKYTOLZLBGTGDATQDVZ4R5APZEAOIA7L32X4UXBH4XNI7MWAC
SJN2QPWHFYKX7CJMW4XZHI2P2THH7MECZZIHQMCH6EKBZ45G3DOAC
RAKTHYAIX757GPYWCHOE5H5RD3QYKQW3QKLWUIUKPHQ5QGWQXWQQC
Z4KRJX4QVMQ5F233DC3XMSE5ZJYHKX3UF5QWAGHDC54EC5NUBXUQC
RH37XKJ27AMZIMB5JW5ZVDYMKHSIEGJNG6XZO4M45FE6V2N2YRIAC
MI4IMCD3HUEA65RYFKUMDHQMQUCQT4MDISCOC25DYREV6SYLZPMQC
A6FXZPKEPNITVXU6DRACBT5DKLMF4A22CFTPKSHSMQDZY4TKMF6AC
S6OISBQ3HPFHAAQ5ENG7N3MNGOPNEJPIFKSSA5N4G6KJQTQBSSLQC
KN3VYE5P2RJB3KZ355LA5C2T2D5S2IR3QZFE53AJIWUVMETEEYDAC
my $projectName = $c->stash->{project}->name;
my $jobsetName = $c->stash->{jobset}->name;
# Get the active / inactive jobs in this jobset.
my @jobs = $c->stash->{jobset}->jobs->search(
{ },
{ select => [
"name",
\("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->{jobset}->builds->search(
{isCurrent => 1},
{select => ["job"], order_by => ["job"], distinct => 1}
)];
$c->stash->{inactiveJobs} = [
$c->stash->{jobset}->builds->search(
{},
{select => ["job"], order_by => ["job"], group_by => ["job"], having => { 'sum(isCurrent)' => 0 }}
)];
$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;
}
}
my @select = ();
my @as = ();
push(@select, "job"); push(@as, "job");
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(@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(@as, $system."-build");
}
$c->stash->{activeJobsStatus} = [$c->model('DB')->resultset('ActiveJobsForJobset')
->search( {}
, { bind => [$c->stash->{project}->name, $c->stash->{jobset}->name]
, select => \@select
, as => \@as
, order_by => ["job"]
})];
}
my @select = ();
my @as = ();
push(@select, "job"); push(@as, "job");
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(@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(@as, $system."-build");
}
$c->stash->{activeJobsStatus} =
[ $c->model('DB')->resultset('ActiveJobsForJobset')->search(
{},
{ bind => [$c->stash->{project}->name, $c->stash->{jobset}->name]
, select => \@select
, as => \@as
, order_by => ["job"]
})];
}
create index IndexBuildInputsByBuild on BuildInputs(build);
create index IndexBuildInputsByDependency on BuildInputs(dependency);
create index IndexBuildsByTimestamp on Builds(timestamp);
create index IndexBuildsByIsCurrent on Builds(isCurrent);
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 IndexBuildInputsOnBuild on BuildInputs(build);
create index IndexBuildInputsOnDependency on BuildInputs(dependency);
create index IndexBuildProducstOnBuildAndType on BuildProducts(build, type);
create index IndexBuildProductsOnBuild on BuildProducts(build);
create index IndexBuildSchedulingInfoByBuild on BuildSchedulingInfo(id); -- idem
create index IndexBuildProductsByBuild on BuildProducts(build);
create index IndexBuildProducstByBuildAndType on BuildProducts(build, type);
create index IndexBuildStepsByBuild on BuildSteps(build);
create index IndexBuildSchedulingInfoOnBuild on BuildSchedulingInfo(id); -- idem
create index IndexBuildStepsOnBuild on BuildSteps(build);
create index IndexBuildsOnFinished on Builds(finished);
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);