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) {
|
sub machines :Local Args(0) {
|
||||||
my ($self, $c) = @_;
|
my ($self, $c) = @_;
|
||||||
my $machines = getMachines;
|
my $machines = getMachines;
|
||||||
my $idles = $c->model('DB::BuildSteps')->search(
|
|
||||||
{ stoptime => { '!=', undef } },
|
# Add entry for localhost.
|
||||||
{ select => [ 'machine', { max => 'stoptime', -as => 'max_stoptime' }], group_by => "machine" });
|
${$machines}{''} //= {};
|
||||||
while (my $idle = $idles->next) {
|
|
||||||
${$machines}{$idle->machine}{'idle'} = $idle->get_column('max_stoptime');
|
# 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->{machines} = $machines;
|
||||||
$c->stash->{steps} = [ $c->model('DB::BuildSteps')->search(
|
$c->stash->{steps} = [ $c->model('DB::BuildSteps')->search(
|
||||||
{ finished => 0, 'me.busy' => 1, 'build.busy' => 1, },
|
{ finished => 0, 'me.busy' => 1, 'build.busy' => 1, },
|
||||||
|
|
|
@ -7,11 +7,7 @@
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="5">
|
<th colspan="5">
|
||||||
[% IF !m.key || m.value.maxJobs %]
|
<tt>[% name %]</tt>
|
||||||
Enabled:
|
|
||||||
[% ELSE %]
|
|
||||||
Disabled:
|
|
||||||
[% END %] <tt>[% name %]</tt>
|
|
||||||
[% IF m.value.systemTypes %]
|
[% IF m.value.systemTypes %]
|
||||||
([% comma=0; FOREACH system IN m.value.systemTypes %][% IF comma; %], [% ELSE; comma = 1; END %]<tt>[% system %]</tt>[% END %])
|
([% comma=0; FOREACH system IN m.value.systemTypes %][% IF comma; %], [% ELSE; comma = 1; END %]<tt>[% system %]</tt>[% END %])
|
||||||
[% END %]
|
[% END %]
|
||||||
|
@ -35,7 +31,7 @@
|
||||||
[% END %]
|
[% END %]
|
||||||
[% IF idle == 1 %]
|
[% IF idle == 1 %]
|
||||||
[% IF m.value.idle %]
|
[% 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 %]
|
[% ELSE %]
|
||||||
<tr><td colspan="5">Never used</td></tr>
|
<tr><td colspan="5">Never used</td></tr>
|
||||||
[% END %]
|
[% END %]
|
||||||
|
|
Loading…
Reference in a new issue