forked from lix-project/hydra
Machine status: Don't show removed machines anymore
This requires a sequential scan on the BuildSteps table, which by now takes > 8s.
This commit is contained in:
parent
b3612b8a81
commit
7528a9c7e7
|
@ -75,12 +75,18 @@ sub status :Local {
|
|||
sub machines :Local Args(0) {
|
||||
my ($self, $c) = @_;
|
||||
my $machines = getMachines;
|
||||
my $idles = $c->model('DB::BuildSteps')->search(
|
||||
{ stoptime => { '!=', undef } },
|
||||
{ select => [ 'machine', { max => 'stoptime', -as => 'max_stoptime' }], group_by => "machine" });
|
||||
while (my $idle = $idles->next) {
|
||||
${$machines}{$idle->machine}{'idle'} = $idle->get_column('max_stoptime');
|
||||
|
||||
# Add entry for localhost.
|
||||
${$machines}{''} //= {};
|
||||
|
||||
# Get the last finished build step for each machine.
|
||||
foreach my $m (keys %{$machines}) {
|
||||
my $idle = $c->model('DB::BuildSteps')->find(
|
||||
{ machine => "$m", stoptime => { '!=', undef } },
|
||||
{ order_by => 'stoptime desc', rows => 1 });
|
||||
${$machines}{$m}{'idle'} = $idle ? $idle->stoptime : 0;
|
||||
}
|
||||
|
||||
$c->stash->{machines} = $machines;
|
||||
$c->stash->{steps} = [ $c->model('DB::BuildSteps')->search(
|
||||
{ finished => 0, 'me.busy' => 1, 'build.busy' => 1, },
|
||||
|
|
|
@ -7,11 +7,7 @@
|
|||
<thead>
|
||||
<tr>
|
||||
<th colspan="5">
|
||||
[% IF !m.key || m.value.maxJobs %]
|
||||
Enabled:
|
||||
[% ELSE %]
|
||||
Disabled:
|
||||
[% END %] <tt>[% name %]</tt>
|
||||
<tt>[% name %]</tt>
|
||||
[% IF m.value.systemTypes %]
|
||||
([% comma=0; FOREACH system IN m.value.systemTypes %][% IF comma; %], [% ELSE; comma = 1; END %]<tt>[% system %]</tt>[% END %])
|
||||
[% END %]
|
||||
|
@ -35,7 +31,7 @@
|
|||
[% END %]
|
||||
[% IF idle == 1 %]
|
||||
[% IF m.value.idle %]
|
||||
<tr><td colspan="5">Idle since [% INCLUDE renderDuration duration = curTime - m.value.idle %]</td></tr>
|
||||
<tr><td colspan="5">Idle for [% INCLUDE renderDuration duration = curTime - m.value.idle %]</td></tr>
|
||||
[% ELSE %]
|
||||
<tr><td colspan="5">Never used</td></tr>
|
||||
[% END %]
|
||||
|
|
Loading…
Reference in a new issue