diff --git a/src/lib/Hydra/Controller/Jobset.pm b/src/lib/Hydra/Controller/Jobset.pm index ffc88a5b..02845ef2 100644 --- a/src/lib/Hydra/Controller/Jobset.pm +++ b/src/lib/Hydra/Controller/Jobset.pm @@ -49,7 +49,7 @@ sub jobsetIndex { } } - $c->stash->{evals} = getEvals($self, $c, 0, 10); + $c->stash->{evals} = getEvals($self, $c, scalar $c->stash->{jobset}->jobsetevals, 0, 10); $c->stash->{systems} = [ $c->stash->{jobset}->builds->search({ iscurrent => 1 }, { select => ["system"], distinct => 1, order_by => "system" }) ]; @@ -303,77 +303,21 @@ sub clone_submit : Chained('jobset') PathPart('clone/submit') Args(0) { } -sub getEvals { - my ($self, $c, $offset, $rows) = @_; - - my @evals = $c->stash->{jobset}->jobsetevals->search( - { hasnewbuilds => 1 }, - { order_by => "id DESC", rows => $rows + 1, offset => $offset }); - - my @res = (); - my $prevInputs = []; - my $prev; - for (my $n = scalar @evals - 1; $n >= 0; $n--) { - my $cur = $evals[$n]; - - # Get stats for this eval. - my $nrScheduled; - my $nrSucceeded = $cur->nrsucceeded; - if (defined $nrSucceeded) { - $nrScheduled = 0; - } else { - $nrScheduled = $cur->builds->search({finished => 0})->count; - $nrSucceeded = $cur->builds->search({finished => 1, buildStatus => 0})->count; - if ($nrScheduled == 0) { - $cur->update({nrsucceeded => $nrSucceeded}); - } - } - - # Compute what inputs changed between each eval. - my $curInputs = [ $cur->jobsetevalinputs->search( - { -or => [ -and => [ uri => { '!=' => undef }, revision => { '!=' => undef }], dependency => { '!=' => undef }], altNr => 0 }, - { order_by => "name" }) ]; - my @changedInputs; - my %prevInputsHash; - $prevInputsHash{$_->name} = $_ foreach @{$prevInputs}; - foreach my $input (@{$curInputs}) { - my $p = $prevInputsHash{$input->name}; - push @changedInputs, $input - if !defined $p || ($input->revision || "") ne ($p->revision || "") || $input->type ne $p->type || ($input->uri || "") ne ($p->uri || "") || - ( defined $input->dependency && defined $p->dependency && $input->dependency->id ne $p->dependency->id); - } - $prevInputs = $curInputs; - - my $e = - { eval => $cur - , nrScheduled => $nrScheduled - , nrSucceeded => $nrSucceeded - , nrFailed => $cur->nrbuilds - $nrSucceeded - $nrScheduled - , diff => defined $prev ? $nrSucceeded - $prev->{nrSucceeded} : 0 - , changedInputs => [ @changedInputs ] - }; - push @res, $e if $n < $rows; - $prev = $e; - } - - return [reverse @res]; -} - - sub evals : Chained('jobset') PathPart('evals') Args(0) { my ($self, $c) = @_; - $c->stash->{template} = 'jobset-evals.tt'; + $c->stash->{template} = 'evals.tt'; my $page = int($c->req->param('page') || "1") || 1; my $resultsPerPage = 20; + my $evals = $c->stash->{jobset}->jobsetevals; + $c->stash->{page} = $page; $c->stash->{resultsPerPage} = $resultsPerPage; - $c->stash->{total} = $c->stash->{jobset}->jobsetevals->search({hasnewbuilds => 1})->count; - - $c->stash->{evals} = getEvals($self, $c, ($page - 1) * $resultsPerPage, $resultsPerPage) + $c->stash->{total} = $evals->search({hasnewbuilds => 1})->count; + $c->stash->{evals} = getEvals($self, $c, $evals, ($page - 1) * $resultsPerPage, $resultsPerPage) } diff --git a/src/lib/Hydra/Controller/Root.pm b/src/lib/Hydra/Controller/Root.pm index 06babef2..74475c1f 100644 --- a/src/lib/Hydra/Controller/Root.pm +++ b/src/lib/Hydra/Controller/Root.pm @@ -281,4 +281,22 @@ sub logo :Local { } +sub evals :Local Args(0) { + my ($self, $c) = @_; + + $c->stash->{template} = 'evals.tt'; + + my $page = int($c->req->param('page') || "1") || 1; + + my $resultsPerPage = 20; + + my $evals = $c->model('DB::JobsetEvals'); + + $c->stash->{page} = $page; + $c->stash->{resultsPerPage} = $resultsPerPage; + $c->stash->{total} = $evals->search({hasnewbuilds => 1})->count; + $c->stash->{evals} = getEvals($self, $c, $evals, ($page - 1) * $resultsPerPage, $resultsPerPage) +} + + 1; diff --git a/src/lib/Hydra/Helper/Nix.pm b/src/lib/Hydra/Helper/Nix.pm index 87a5c797..9c312c1d 100644 --- a/src/lib/Hydra/Helper/Nix.pm +++ b/src/lib/Hydra/Helper/Nix.pm @@ -15,7 +15,8 @@ our @EXPORT = qw( getPrimaryBuildTotal getViewResult getLatestSuccessfulViewResult jobsetOverview removeAsciiEscapes getDrvLogPath logContents - getMainOutput); + getMainOutput + getEvals); sub getHydraHome { @@ -287,4 +288,61 @@ sub getMainOutput { } +sub getEvals { + my ($self, $c, $evals, $offset, $rows) = @_; + + my @evals = $evals->search( + { hasnewbuilds => 1 }, + { order_by => "id DESC", rows => $rows + 1, offset => $offset }); + + my @res = (); + my $prevInputs = []; + my $prev; + for (my $n = scalar @evals - 1; $n >= 0; $n--) { + my $cur = $evals[$n]; + + # Get stats for this eval. + my $nrScheduled; + my $nrSucceeded = $cur->nrsucceeded; + if (defined $nrSucceeded) { + $nrScheduled = 0; + } else { + $nrScheduled = $cur->builds->search({finished => 0})->count; + $nrSucceeded = $cur->builds->search({finished => 1, buildStatus => 0})->count; + if ($nrScheduled == 0) { + $cur->update({nrsucceeded => $nrSucceeded}); + } + } + + # Compute what inputs changed between each eval. + my $curInputs = [ $cur->jobsetevalinputs->search( + { -or => [ -and => [ uri => { '!=' => undef }, revision => { '!=' => undef }], dependency => { '!=' => undef }], altNr => 0 }, + { order_by => "name" }) ]; + my @changedInputs; + my %prevInputsHash; + $prevInputsHash{$_->name} = $_ foreach @{$prevInputs}; + foreach my $input (@{$curInputs}) { + my $p = $prevInputsHash{$input->name}; + push @changedInputs, $input + if !defined $p || ($input->revision || "") ne ($p->revision || "") || $input->type ne $p->type || ($input->uri || "") ne ($p->uri || "") || + ( defined $input->dependency && defined $p->dependency && $input->dependency->id ne $p->dependency->id); + } + $prevInputs = $curInputs; + + my $e = + { eval => $cur + , nrScheduled => $nrScheduled + , nrSucceeded => $nrSucceeded + , nrFailed => $cur->nrbuilds - $nrSucceeded - $nrScheduled + , diff => defined $prev ? $nrSucceeded - $prev->{nrSucceeded} : 0 + , changedInputs => [ @changedInputs ] + }; + push @res, $e if $n < $rows; + $prev = $e; + } + + return [reverse @res]; +} + + 1; diff --git a/src/root/common.tt b/src/root/common.tt index 64536ed7..77bddbf5 100644 --- a/src/root/common.tt +++ b/src/root/common.tt @@ -384,10 +384,13 @@ BLOCK renderEvals %]
Jobset | + [% END %]# | -Date | +Date | Input changes | -Success | +Success | ||
---|---|---|---|---|---|---|---|---|
[% INCLUDE renderFullJobsetName project=eval.get_column('project') jobset=eval.get_column('jobset') %] | + [% END %][% eval.id %] | [% INCLUDE renderDateTime timestamp = eval.timestamp %] |
@@ -402,7 +408,7 @@ BLOCK renderEvals %]
sep='';
FOREACH input IN e.changedInputs;
sep; %] [% input.name %] → [% INCLUDE renderShortEvalInput input=input;
- sep=',';
+ sep=', ';
END;
ELSE %]
-
diff --git a/src/root/error.tt b/src/root/error.tt
index ce216c70..928c1baa 100644
--- a/src/root/error.tt
+++ b/src/root/error.tt
@@ -1,12 +1,8 @@
[% WRAPPER layout.tt title=(httpStatus ? httpStatus : "Error") %]
[% USE HTML %]
- I'm very sorry, but the following error(s) occurred: - -
[% HTML.escape(error) %]
[% END %]
-Showing evaluations [% (page - 1) * resultsPerPage + 1 %] - [% diff --git a/src/root/topbar.tt b/src/root/topbar.tt index f3164ef4..2d35b834 100644 --- a/src/root/topbar.tt +++ b/src/root/topbar.tt @@ -36,6 +36,9 @@ [% INCLUDE makeLink uri = c.uri_for(c.controller('Root').action_for('machines')) title = "Machine status" %] + [% INCLUDE makeLink + uri = c.uri_for(c.controller('Root').action_for('evals')) + title = "Latest evaluations" %] [% INCLUDE makeLink uri = c.uri_for(c.controller('Root').action_for('all')) title = "Latest builds" %] |