Speed up the jobset eval list a bit

This commit is contained in:
Eelco Dolstra 2012-04-15 22:11:20 +00:00
parent 573a333bc9
commit 034d50069b
2 changed files with 22 additions and 21 deletions

View file

@ -330,23 +330,18 @@ sub getEvals {
my @evals = $c->stash->{jobset}->jobsetevals->search( my @evals = $c->stash->{jobset}->jobsetevals->search(
{ hasnewbuilds => 1 }, { hasnewbuilds => 1 },
{ order_by => "id DESC" { order_by => "id DESC", rows => $rows + 1, offset => $offset });
, '+select' => # !!! Slow - should precompute this.
[ "(select count(*) from JobsetEvalMembers where eval = me.id)"
, "(select count(*) from JobsetEvalMembers where eval = me.id and exists(select 1 from Builds b where b.id = build and b.finished = 0))"
, "(select count(*) from JobsetEvalMembers where eval = me.id and exists(select 1 from Builds b where b.id = build and b.finished = 1))"
, "(select count(*) from JobsetEvalMembers where eval = me.id and exists(select 1 from Builds b where b.id = build and b.finished = 1 and b.buildStatus = 0))"
]
, '+as' => [ "nrBuilds", "nrScheduled", "nrFinished", "nrSucceeded" ]
, rows => $rows + 1
, offset => $offset
});
my @res = (); my @res = ();
my $prevInputs = []; my $prevInputs = [];
my $prev;
for (my $n = scalar @evals - 1; $n >= 0; $n--) { for (my $n = scalar @evals - 1; $n >= 0; $n--) {
my $cur = $evals[$n]; my $cur = $evals[$n];
my $prev = $evals[$n + 1];
# Get stats for this eval.
my $nrBuilds = $cur->jobsetevalmembers->count;
my $nrScheduled = $cur->builds->search({finished => 0})->count;
my $nrSucceeded = $cur->builds->search({finished => 1, buildStatus => 0})->count;
# Compute what inputs changed between each eval. # Compute what inputs changed between each eval.
my $curInputs = [ $cur->jobsetevalinputs->search( my $curInputs = [ $cur->jobsetevalinputs->search(
@ -362,14 +357,20 @@ sub getEvals {
} }
$prevInputs = $curInputs; $prevInputs = $curInputs;
push @res, my $e =
{ eval => $cur { eval => $cur
, diff => defined $prev ? $cur->get_column("nrSucceeded") - $prev->get_column("nrSucceeded") : 0 , nrBuilds => $nrBuilds
, nrScheduled => $nrScheduled
, nrSucceeded => $nrSucceeded
, nrFailed => $nrBuilds - $nrSucceeded - $nrScheduled
, diff => defined $prev ? $nrSucceeded - $prev->{nrSucceeded} : 0
, changedInputs => [ @changedInputs ] , changedInputs => [ @changedInputs ]
}; };
push @res, $e if $n < $rows;
$prev = $e;
} }
return [(reverse @res)[0..$rows - 1]]; return [reverse @res];
} }

View file

@ -439,16 +439,16 @@
[%- END -%] [%- END -%]
</td> </td>
<td align='right'> <td align='right'>
<span class="label label-success">[% eval.get_column('nrSucceeded') %]</span> <span class="label label-success">[% e.nrSucceeded %]</span>
<span class="label label-important">[% eval.get_column('nrBuilds') - eval.get_column('nrSucceeded') - eval.get_column('nrScheduled') %]</span> <span class="label label-important">[% e.nrFailed %]</span>
[% IF eval.get_column('nrScheduled') > 0 %] [% IF e.nrScheduled > 0 %]
<span class="label">[% eval.get_column('nrScheduled') %]</span> <span class="label">[% e.nrScheduled %]</span>
[% END %] [% END %]
</td> </td>
<td align='right'> <td align='right'>
[%- IF e.diff > 0 -%] [%- IF e.diff > 0 -%]
<span class='label label-success'><strong>+[% e.diff %]</strong></span> <span class='label label-success'><strong>+[% e.diff %]</strong></span>
[%- ELSIF e.diff < 0 && eval.get_column('nrScheduled') == 0 -%] [%- ELSIF e.diff < 0 && e.nrScheduled == 0 -%]
<span class='label label-important'><strong>[% e.diff %]</strong></span> <span class='label label-important'><strong>[% e.diff %]</strong></span>
[%- END -%] [%- END -%]
</td> </td>