forked from lix-project/hydra
Jobset page: Load the jobs and status tabs on demand
This makes the jobset page much smaller and faster. (E.g. for nixpkgs:trunk, this page was ~2.5 MB.)
This commit is contained in:
parent
f2de374f28
commit
629fe6f998
|
@ -21,37 +21,54 @@ sub jobset : Chained('/') PathPart('jobset') CaptureArgs(2) {
|
|||
}
|
||||
|
||||
|
||||
sub jobsetIndex {
|
||||
my ($self, $c, $forceStatus) = @_;
|
||||
sub index : Chained('jobset') PathPart('') Args(0) {
|
||||
my ($self, $c) = @_;
|
||||
|
||||
$c->stash->{template} = 'jobset.tt';
|
||||
|
||||
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->{inactiveJobs} = [];
|
||||
foreach my $job (@jobs) {
|
||||
if ($job->get_column('active')) {
|
||||
push @{$c->stash->{activeJobs}}, $job->name;
|
||||
} else {
|
||||
push @{$c->stash->{inactiveJobs}}, $job->name;
|
||||
}
|
||||
}
|
||||
|
||||
$c->stash->{evals} = getEvals($self, $c, scalar $c->stash->{jobset}->jobsetevals, 0, 10);
|
||||
|
||||
($c->stash->{latestEval}) = $c->stash->{jobset}->jobsetevals->search({}, { limit => 1, order_by => ["id desc"] });
|
||||
}
|
||||
|
||||
|
||||
sub jobs_tab : Chained('jobset') PathPart('jobs-tab') Args(0) {
|
||||
my ($self, $c) = @_;
|
||||
$c->stash->{template} = 'jobset-jobs-tab.tt';
|
||||
|
||||
$c->stash->{activeJobs} = [];
|
||||
$c->stash->{inactiveJobs} = [];
|
||||
|
||||
(my $latestEval) = $c->stash->{jobset}->jobsetevals->search(
|
||||
{ hasnewbuilds => 1}, { limit => 1, order_by => ["id desc"] });
|
||||
|
||||
my %activeJobs;
|
||||
if (defined $latestEval) {
|
||||
foreach my $build ($latestEval->builds->search({}, { order_by => ["job"], select => ["job"] })) {
|
||||
my $job = $build->get_column("job");
|
||||
if (!defined $activeJobs{$job}) {
|
||||
$activeJobs{$job} = 1;
|
||||
push @{$c->stash->{activeJobs}}, $job;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach my $job ($c->stash->{jobset}->jobs->search({}, { order_by => ["name"] })) {
|
||||
if (!defined $activeJobs{$job->name}) {
|
||||
push @{$c->stash->{inactiveJobs}}, $job->name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub status_tab : Chained('jobset') PathPart('status-tab') Args(0) {
|
||||
my ($self, $c) = @_;
|
||||
$c->stash->{template} = 'jobset-status-tab.tt';
|
||||
|
||||
# FIXME: use latest eval instead of iscurrent.
|
||||
|
||||
$c->stash->{systems} =
|
||||
[ $c->stash->{jobset}->builds->search({ iscurrent => 1 }, { select => ["system"], distinct => 1, order_by => "system" }) ];
|
||||
|
@ -62,38 +79,24 @@ sub jobsetIndex {
|
|||
push(@systems, $system->system);
|
||||
}
|
||||
|
||||
if($forceStatus || scalar(@{$c->stash->{activeJobs}}) <= 100) {
|
||||
my @select = ();
|
||||
my @as = ();
|
||||
push(@select, "job"); push(@as, "job");
|
||||
foreach my $system (@systems) {
|
||||
push(@select, "(select buildstatus from 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' and t.iscurrent = 1 ))");
|
||||
push(@as, $system);
|
||||
push(@select, "(select b.id from 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' and t.iscurrent = 1 ))");
|
||||
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 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' and t.iscurrent = 1 ))");
|
||||
push(@as, $system);
|
||||
push(@select, "(select b.id from 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' and t.iscurrent = 1 ))");
|
||||
push(@as, "$system-build");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
sub index : Chained('jobset') PathPart('') Args(0) {
|
||||
my ($self, $c) = @_;
|
||||
jobsetIndex($self, $c, 0);
|
||||
}
|
||||
|
||||
|
||||
sub indexWithStatus : Chained('jobset') PathPart('') Args(1) {
|
||||
my ($self, $c, $forceStatus) = @_;
|
||||
jobsetIndex($self, $c, 1);
|
||||
$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"]
|
||||
}) ];
|
||||
}
|
||||
|
||||
|
||||
|
|
15
src/root/jobset-jobs-tab.tt
Normal file
15
src/root/jobset-jobs-tab.tt
Normal file
|
@ -0,0 +1,15 @@
|
|||
[% PROCESS common.tt %]
|
||||
|
||||
<p>This jobset currently contains the following [% activeJobs.size %] jobs:
|
||||
<blockquote>
|
||||
[% IF activeJobs.size == 0 %]<em>(none)</em>[% END %]
|
||||
[% FOREACH j IN activeJobs %][% INCLUDE renderJobName project=project.name jobset=jobset.name job=j %]<br/>[% END %]
|
||||
</blockquote>
|
||||
</p>
|
||||
|
||||
<p>This jobset used to contain the following [% inactiveJobs.size %] jobs:
|
||||
<blockquote>
|
||||
[% IF inactiveJobs.size == 0 %]<em>(none)</em>[% END %]
|
||||
[% FOREACH j IN inactiveJobs %][% INCLUDE renderJobName project=project.name jobset=jobset.name job=j %]<br/>[% END %]
|
||||
</blockquote>
|
||||
</p>
|
24
src/root/jobset-status-tab.tt
Normal file
24
src/root/jobset-status-tab.tt
Normal file
|
@ -0,0 +1,24 @@
|
|||
[% PROCESS common.tt %]
|
||||
|
||||
<table class="table table-striped table-condensed">
|
||||
<thead><tr><th>Job</th>[% FOREACH s IN systems %]<th>[% s.system %]</th>[% END %]</tr></thead>
|
||||
<tbody>
|
||||
[% odd = 0 %]
|
||||
[% FOREACH j IN activeJobsStatus %]
|
||||
<tr class="[% IF odd %] odd [% END; odd = !odd %]">
|
||||
<td>[% INCLUDE renderJobName project=project.name jobset = jobset.name job = j.get_column('job') %]</td>
|
||||
[% FOREACH s IN systems %]
|
||||
[% system = s.system %]
|
||||
[% systemStatus = j.get_column(system) %]
|
||||
<td class="centered">
|
||||
[% IF systemStatus != undef %]
|
||||
<a href="[% c.uri_for('/build' j.get_column(system _ '-build') ) %]">
|
||||
[% INCLUDE renderBuildStatusIcon buildstatus=systemStatus size=16 %]
|
||||
</a>
|
||||
[% END %]
|
||||
</td>
|
||||
[% END %]
|
||||
</tr>
|
||||
[% END %]
|
||||
</tbody>
|
||||
</table>
|
|
@ -46,7 +46,7 @@
|
|||
<li><a href="#tabs-errors" data-toggle="tab"><img src="/static/images/error_16.png" /> Evaluation errors</a></li>
|
||||
[% END %]
|
||||
<li><a href="#tabs-status" data-toggle="tab">Job status</a></li>
|
||||
<li><a href="#tabs-jobs" data-toggle="tab">Jobs ([% activeJobs.size %])</a></li>
|
||||
<li><a href="#tabs-jobs" data-toggle="tab">Jobs</a></li>
|
||||
<li><a href="#tabs-setup" data-toggle="tab">Configuration</a></li>
|
||||
</ul>
|
||||
|
||||
|
@ -86,39 +86,7 @@
|
|||
|
||||
</div>
|
||||
|
||||
<div id="tabs-status" class="tab-pane">
|
||||
|
||||
[% IF activeJobsStatus %]
|
||||
<table class="table table-striped table-condensed">
|
||||
<thead><tr><th>Job</th>[% FOREACH s IN systems %]<th>[% s.system %]</th>[% END %]</tr></thead>
|
||||
<tbody>
|
||||
[% odd = 0 %]
|
||||
[% FOREACH j IN activeJobsStatus %]
|
||||
<tr class="[% IF odd %] odd [% END; odd = !odd %]">
|
||||
<td>[% INCLUDE renderJobName project=project.name jobset = jobset.name job = j.get_column('job') %]</td>
|
||||
[% FOREACH s IN systems %]
|
||||
[% system = s.system %]
|
||||
[% systemStatus = j.get_column(system) %]
|
||||
<td class="centered">
|
||||
[% IF systemStatus != undef %]
|
||||
<a href="[% c.uri_for('/build' j.get_column(system _ '-build') ) %]">
|
||||
[% INCLUDE renderBuildStatusIcon buildstatus=systemStatus size=16 %]
|
||||
</a>
|
||||
[% END %]
|
||||
</td>
|
||||
[% END %]
|
||||
</tr>
|
||||
[% END %]
|
||||
</tbody>
|
||||
</table>
|
||||
[% ELSE %]
|
||||
<h2>Status</h2>
|
||||
<p>
|
||||
[ <a href="[% c.uri_for('/jobset' project.name jobset.name 'with-status' ) %]">Show status overview</a> ]
|
||||
</p>
|
||||
[% END %]
|
||||
|
||||
</div>
|
||||
[% INCLUDE makeLazyTab tabName="tabs-status" uri=c.uri_for('/jobset' project.name jobset.name "status-tab") %]
|
||||
|
||||
[% IF jobset.errormsg %]
|
||||
<div id="tabs-errors" class="tab-pane">
|
||||
|
@ -164,23 +132,7 @@
|
|||
[% INCLUDE renderInputs %]
|
||||
</div>
|
||||
|
||||
<div id="tabs-jobs" class="tab-pane">
|
||||
|
||||
<p>This jobset currently contains the following [% activeJobs.size %] jobs:
|
||||
<blockquote>
|
||||
[% IF activeJobs.size == 0 %]<em>(none)</em>[% END %]
|
||||
[% FOREACH j IN activeJobs %][% INCLUDE renderJobName project=project.name jobset=jobset.name job=j %]<br/>[% END %]
|
||||
</blockquote>
|
||||
</p>
|
||||
|
||||
<p>This jobset used to contain the following [% inactiveJobs.size %] jobs:
|
||||
<blockquote>
|
||||
[% IF inactiveJobs.size == 0 %]<em>(none)</em>[% END %]
|
||||
[% FOREACH j IN inactiveJobs %][% INCLUDE renderJobName project=project.name jobset=jobset.name job=j %]<br/>[% END %]
|
||||
</blockquote>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
[% INCLUDE makeLazyTab tabName="tabs-jobs" uri=c.uri_for('/jobset' project.name jobset.name "jobs-tab") %]
|
||||
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in a new issue