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:
@ -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, },
|
||||
|
Reference in New Issue
Block a user