From b9824ca422aa59e2b9da8ae75df12f390234a427 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sun, 15 Apr 2012 18:47:22 +0000 Subject: [PATCH] Cleanup --- src/lib/Hydra/Controller/Jobset.pm | 48 +++++++++++++----------------- src/root/jobset.tt | 4 +-- 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/src/lib/Hydra/Controller/Jobset.pm b/src/lib/Hydra/Controller/Jobset.pm index ce230a16..961ac0ee 100644 --- a/src/lib/Hydra/Controller/Jobset.pm +++ b/src/lib/Hydra/Controller/Jobset.pm @@ -49,19 +49,7 @@ sub jobsetIndex { } } - $c->stash->{evals} = [ $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 => 6 - } - ) ]; + $c->stash->{evals} = getEvals($self, $c, 0, 6); $c->stash->{systems} = [ $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) { my ($self, $c) = @_; @@ -350,20 +357,7 @@ sub evals : Chained('jobset') PathPart('evals') Args(0) { $c->stash->{resultsPerPage} = $resultsPerPage; $c->stash->{total} = $c->stash->{jobset}->jobsetevals->search({hasnewbuilds => 1})->count; - $c->stash->{evals} = [ $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 => $resultsPerPage + 1 - , offset => ($page - 1) * $resultsPerPage - } - ) ]; + $c->stash->{evals} = getEvals($self, $c, ($page - 1) * $resultsPerPage, $resultsPerPage + 1) } diff --git a/src/root/jobset.tt b/src/root/jobset.tt index 4b6faed1..e832eb58 100644 --- a/src/root/jobset.tt +++ b/src/root/jobset.tt @@ -81,9 +81,9 @@
- [% IF !edit-%] + [% IF !edit && evals.size() > 0 -%]

Most recent evaluations

- [% 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 %] [% IF !edit && activeJobsStatus -%]

Status