Document getEvals a bit

Also drop the $self parameter.

Co-authored-by: gustavderdrache
This commit is contained in:
Graham Christensen 2021-06-16 12:42:25 -04:00
parent 5d95abf540
commit 09ad52ab60
4 changed files with 34 additions and 7 deletions

View file

@ -558,7 +558,7 @@ sub evals : Chained('buildChain') PathPart('evals') Args(0) {
$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)
$c->stash->{evals} = getEvals($c, $evals, ($page - 1) * $resultsPerPage, $resultsPerPage)
}

View file

@ -41,7 +41,7 @@ sub jobset_GET {
$c->stash->{template} = 'jobset.tt';
$c->stash->{evals} = getEvals($self, $c, scalar $c->stash->{jobset}->jobsetevals, 0, 10);
$c->stash->{evals} = getEvals($c, scalar $c->stash->{jobset}->jobsetevals, 0, 10);
$c->stash->{latestEval} = $c->stash->{jobset}->jobsetevals->search({ hasnewbuilds => 1 }, { rows => 1, order_by => ["id desc"] })->single;
@ -337,7 +337,7 @@ sub evals_GET {
$c->stash->{resultsPerPage} = $resultsPerPage;
$c->stash->{total} = $evals->search({hasnewbuilds => 1})->count;
my $offset = ($page - 1) * $resultsPerPage;
$c->stash->{evals} = getEvals($self, $c, $evals, $offset, $resultsPerPage);
$c->stash->{evals} = getEvals($c, $evals, $offset, $resultsPerPage);
my %entity = (
evals => [ map { $_->{eval} } @{$c->stash->{evals}} ],
first => "?page=1",

View file

@ -398,7 +398,7 @@ sub evals :Local Args(0) {
$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);
$c->stash->{evals} = getEvals($c, $evals, ($page - 1) * $resultsPerPage, $resultsPerPage);
$self->status_ok($c, entity => $c->stash->{evals});
}

View file

@ -223,12 +223,39 @@ sub getEvalInfo {
}
=head2 getEvals
This method returns a list of evaluations with details about what changed,
intended to be used with `eval.tt`.
Arguments:
=over 4
=item C<$c>
L<Hydra> - the entire application.
=item C<$evals_result_set>
A L<DBIx::Class::ResultSet> for the result class of L<Hydra::Model::DB::JobsetEvals>
=item C<$offset>
Integer offset when selecting evaluations
=item C<$rows>
Integer rows to fetch
=back
=cut
sub getEvals {
my ($self, $c, $evals_query_builder, $offset, $rows) = @_;
my ($c, $evals_result_set, $offset, $rows) = @_;
my $me = $evals_query_builder->current_source_alias;
my $me = $evals_result_set->current_source_alias;
my @evals = $evals_query_builder->search(
my @evals = $evals_result_set->search(
{ hasnewbuilds => 1 },
{ order_by => "$me.id DESC", rows => $rows, offset => $offset
, prefetch => { evaluationerror => [ ] } });