This commit is contained in:
Eelco Dolstra 2012-04-15 18:47:22 +00:00
parent fd50ac1d4e
commit b9824ca422
2 changed files with 23 additions and 29 deletions

View file

@ -49,19 +49,7 @@ sub jobsetIndex {
} }
} }
$c->stash->{evals} = [ $c->stash->{jobset}->jobsetevals->search( $c->stash->{evals} = getEvals($self, $c, 0, 6);
{ hasnewbuilds => 1 },
{ order_by => "id DESC"
, '+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 => 6
}
) ];
$c->stash->{systems} = $c->stash->{systems} =
[ $c->stash->{jobset}->builds->search({ iscurrent => 1 }, { select => ["system"], distinct => 1, order_by => "system" }) ]; [ $c->stash->{jobset}->builds->search({ iscurrent => 1 }, { select => ["system"], distinct => 1, order_by => "system" }) ];
@ -337,6 +325,25 @@ sub clone_submit : Chained('jobset') PathPart('clone/submit') Args(0) {
} }
sub getEvals {
my ($self, $c, $offset, $rows) = @_;
return [ $c->stash->{jobset}->jobsetevals->search(
{ hasnewbuilds => 1 },
{ order_by => "id DESC"
, '+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
, offset => $offset
}
) ];
}
sub evals : Chained('jobset') PathPart('evals') Args(0) { sub evals : Chained('jobset') PathPart('evals') Args(0) {
my ($self, $c) = @_; my ($self, $c) = @_;
@ -350,20 +357,7 @@ sub evals : Chained('jobset') PathPart('evals') Args(0) {
$c->stash->{resultsPerPage} = $resultsPerPage; $c->stash->{resultsPerPage} = $resultsPerPage;
$c->stash->{total} = $c->stash->{jobset}->jobsetevals->search({hasnewbuilds => 1})->count; $c->stash->{total} = $c->stash->{jobset}->jobsetevals->search({hasnewbuilds => 1})->count;
$c->stash->{evals} = [ $c->stash->{jobset}->jobsetevals->search( $c->stash->{evals} = getEvals($self, $c, ($page - 1) * $resultsPerPage, $resultsPerPage + 1)
{ hasnewbuilds => 1 },
{ order_by => "id DESC"
, '+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 => $resultsPerPage + 1
, offset => ($page - 1) * $resultsPerPage
}
) ];
} }

View file

@ -81,9 +81,9 @@
</ul> </ul>
<div id="generic-tabs" class="tab-content"> <div id="generic-tabs" class="tab-content">
<div id="tabs-information" class="tab-pane active"> <div id="tabs-information" class="tab-pane active">
[% IF !edit-%] [% IF !edit && evals.size() > 0 -%]
<h2>Most recent evaluations</h2> <h2>Most recent evaluations</h2>
[% INCLUDE renderEvals nrShown=5 linkToAll=c.uri_for(c.controller('Jobset').action_for('evals'), [project.name, jobset.name]) %] [% INCLUDE renderEvals nrShown=evals.size() - 1 linkToAll=c.uri_for(c.controller('Jobset').action_for('evals'), [project.name, jobset.name]) %]
[% END %] [% END %]
[% IF !edit && activeJobsStatus -%] [% IF !edit && activeJobsStatus -%]
<h2>Status</h2> <h2>Status</h2>