lib/Test2/Harness/UI/Controller/Recent.pm untested

filter: Statementstmt 0.0% 0 / 41 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 55 CC 2 SCAR 10.6
CC
2
Cov
0%
handle
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.9
1 package Test2::Harness::UI::Controller::Recent;
2 use strict;
3 use warnings;
4  
5 our $VERSION = '0.000150';
6  
7 use Data::GUID;
8 use Test2::Harness::UI::Response qw/resp error/;
9 use Test2::Harness::Util::JSON qw/encode_json/;
10  
11 use parent 'Test2::Harness::UI::Controller';
12 use Test2::Harness::UI::Util::HashBase qw/-title/;
13  
14 sub handle {
15 my $self = shift;
16 my ($route) = @_;
17  
18 my $req = $self->{+REQUEST};
19  
20 my $res = resp(200);
21  
22 die error(404 => 'Missing route') unless $route;
23  
24 my $project_name = $route->{project};
25 my $user_name = $route->{user};
26 my $count = $route->{count} || 10;
27  
28 my $schema = $self->{+CONFIG}->schema;
29 my $runs = $schema->vague_run_search(
30 username => $user_name,
31 project_name => $project_name,
32 query => {},
33 attrs => {order_by => {'-desc' => 'run_ord'}, rows => $count},
34 list => 1,
35 );
36  
37 my $data = [];
38  
39 while (my $run = $runs->next) {
40 push @$data => $run->TO_JSON;
41 }
42  
43 $res->content_type('application/json');
44 $res->raw_body($data);
45 return $res;
46 }
47  
48 1;
49  
50 __END__