« blib/lib/Tapper/Reports/Web/Controller/Tapper/Testplan/Id.pm
↑ Summary
blib/lib/Tapper/Reports/Web/Util/Filter/Testrun.pm »
| 1 | package Tapper::Reports::Web::Controller::Tapper::Reports; | ||||||||||||||||||||||||||||
| 2 | 14 | our $AUTHORITY = 'cpan:TAPPER'; | |||||||||||||||||||||||||||
| 3 | 14 | $Tapper::Reports::Web::Controller::Tapper::Reports::VERSION = '5.0.17'; | |||||||||||||||||||||||||||
| 4 | 14 | ▶ | use parent 'Tapper::Reports::Web::Controller::Base'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 14 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 14 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 14 | ▶ | use DateTime::Format::Natural; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 14 | ▶ | use DateTime::Format::Strptime; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 14 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 14 | ▶ | use Tapper::Reports::Web::Util::Filter::Report; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 14 | ▶ | use Tapper::Reports::Web::Util::Report; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 2 | ▶ | sub index :Path :Args() { | ||||||||||||||||||||||||||
|
Subroutine
index: called CC=4 SCAR=15.7
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 2 | my ( $self, $c, @args ) = @_; | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 2 | ▶ | exit 0 if $args[0] eq 'exit'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 2 | my $filter = Tapper::Reports::Web::Util::Filter::Report->new(context => $c); | |||||||||||||||||||||||||||
| 24 | 2 | my $filter_condition = $filter->parse_filters(\@args); | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 2 | ▶ | if ($filter_condition->{error}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | 0 | $c->flash->{error_msg} = join("; ", @{$filter_condition->{error}}); | |||||||||||||||||||||||||||
| 28 | 0 | $c->res->redirect("/tapper/reports"); | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | $c->stash->{requested_day} = | ||||||||||||||||||||||||||||
| 33 | 2 | ▶ | $filter->requested_day || DateTime::Format::Natural->new->parse_datetime("today at midnight"); | ||||||||||||||||||||||||||
|
Condition33%1/3
$filter->requested_day || 'DateTime::Format::Natural'->new->parse_datetime('today at midnight')
MC/DC0%0/2
$filter->requested_day || 'DateTime::Format::Natural'->new->parse_datetime('today at midnight')
$filter->requested_day
'DateTime::Format::Natural'->new->parse_datetime('today at midnight')
Truth table33%1/3
A || B
A= $filter->requested_dayB= 'DateTime::Format::Natural'->new->parse_datetime('today at midnight')
| |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 2 | $filter->{early}->{-or} = [{rga_primary => 1}, {rgt_primary => 1}]; | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 2 | $c->forward('/tapper/reports/prepare_this_weeks_reportlists', [ $filter_condition ]); | |||||||||||||||||||||||||||
| 38 | 2 | $c->forward('/tapper/reports/prepare_navi'); | |||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 14 | ▶ | } | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 2 | ▶ | sub prepare_this_weeks_reportlists : Private { | ||||||||||||||||||||||||||
|
Subroutine
prepare_this_weeks_reportlists: called CC=10 SCAR=26.7
Pod
undocumented
| |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 2 | my ( $or_self, $or_c, $hr_filter_condition ) = @_; | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 2 | my $b_view_pager = 0; | |||||||||||||||||||||||||||
| 47 | 2 | my $hr_params = $or_c->req->params; | |||||||||||||||||||||||||||
| 48 | my $hr_query_vals = { | ||||||||||||||||||||||||||||
| 49 | report_id => $hr_filter_condition->{report_id}, | ||||||||||||||||||||||||||||
| 50 | suite_id => $hr_filter_condition->{suite_id}, | ||||||||||||||||||||||||||||
| 51 | machine_name => $hr_filter_condition->{host}, | ||||||||||||||||||||||||||||
| 52 | success_ratio => $hr_filter_condition->{success_ratio}, | ||||||||||||||||||||||||||||
| 53 | successgrade => $hr_filter_condition->{successgrade}, | ||||||||||||||||||||||||||||
| 54 | owner => $hr_filter_condition->{owner}, | ||||||||||||||||||||||||||||
| 55 | 2 | }; | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 2 | require DateTime; | |||||||||||||||||||||||||||
| 58 | 2 | ▶ | if ( $hr_params->{report_date} ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 59 | $hr_filter_condition->{report_date} = DateTime::Format::Strptime->new( | ||||||||||||||||||||||||||||
| 60 | pattern => '%F', | ||||||||||||||||||||||||||||
| 61 | 1 | )->parse_datetime( $hr_params->{report_date} ); | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | elsif (! $hr_filter_condition->{report_id} ) { | ||||||||||||||||||||||||||||
| 64 | 1 | $hr_filter_condition->{report_date} = DateTime->now(); | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | 2 | ▶ | if ( $hr_params->{pager_sign} && $hr_params->{pager_value} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$hr_params->{"pager_sign"} and $hr_params->{"pager_value"}
MC/DC0%0/2
$hr_params->{"pager_sign"} and $hr_params->{"pager_value"}
$hr_params->{"pager_sign"}
$hr_params->{"pager_value"}
Truth table33%1/3
A and B
A= $hr_params->{"pager_sign"}B= $hr_params->{"pager_value"}
| |||||||||||||||||||||||||||||
| 67 | 0 | ▶ | if ( $hr_params->{pager_sign} eq 'negative' ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 68 | $hr_filter_condition->{report_date}->subtract( | ||||||||||||||||||||||||||||
| 69 | 0 | $hr_params->{pager_value} => 1 | |||||||||||||||||||||||||||
| 70 | ); | ||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | elsif ( $hr_params->{pager_sign} eq 'positive' ) { | ||||||||||||||||||||||||||||
| 73 | $hr_filter_condition->{report_date}->add( | ||||||||||||||||||||||||||||
| 74 | 0 | $hr_params->{pager_value} => 1 | |||||||||||||||||||||||||||
| 75 | ); | ||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 2 | ▶ | if ( $hr_filter_condition->{report_date} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 2 | ▶ | $or_c->stash->{pager_interval} = $hr_params->{pager_interval} || 1; | ||||||||||||||||||||||||||
|
Condition50%1/2
$hr_params->{'pager_interval'} || 1
MC/DC0%0/1
$hr_params->{'pager_interval'} || 1
$hr_params->{'pager_interval'}
Truth table50%1/2
A
A= $hr_params->{'pager_interval'}
| |||||||||||||||||||||||||||||
| 82 | 2 | $or_c->stash->{report_date} = $hr_filter_condition->{report_date}; | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | # set report date | ||||||||||||||||||||||||||||
| 85 | 2 | my $d_report_date_from = $hr_filter_condition->{report_date}->clone->subtract( days => $or_c->stash->{pager_interval} - 1 )->strftime('%d %b %Y'); | |||||||||||||||||||||||||||
| 86 | 2 | my $d_report_date_to = $hr_filter_condition->{report_date}->strftime('%d %b %Y'); | |||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 2 | ▶ | if ( $d_report_date_from ne $d_report_date_to ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | 0 | $or_c->stash->{head_overview} = "Reports ($d_report_date_to - $d_report_date_from)"; | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | else { | ||||||||||||||||||||||||||||
| 92 | 2 | $or_c->stash->{head_overview} = "Reports ($d_report_date_from)"; | |||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 2 | $hr_query_vals->{report_date_from} = $hr_filter_condition->{report_date}->clone->subtract( days => $or_c->stash->{pager_interval} - 1 )->strftime('%F'); | |||||||||||||||||||||||||||
| 96 | 2 | $hr_query_vals->{report_date_to} = $hr_filter_condition->{report_date}->strftime('%F'); | |||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 2 | $or_c->stash->{view_pager} = 1; | |||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | else { | ||||||||||||||||||||||||||||
| 102 | 0 | $or_c->stash->{head_overview} = 'Testruns'; | |||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 2 | $or_c->stash->{reports} = $or_c->model('TestrunDB')->fetch_raw_sql({ | |||||||||||||||||||||||||||
| 106 | query_name => 'reports::web_list', | ||||||||||||||||||||||||||||
| 107 | fetch_type => '@%', | ||||||||||||||||||||||||||||
| 108 | query_vals => $hr_query_vals, | ||||||||||||||||||||||||||||
| 109 | }); | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 2 | return 1; | |||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 14 | ▶ | } | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 2 | ▶ | sub prepare_navi : Private { | ||||||||||||||||||||||||||
|
Subroutine
prepare_navi: called CC=4 SCAR=17.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 2 | my ( $self, $c ) = @_; | |||||||||||||||||||||||||||
| 119 | 2 | $c->stash->{navi} = []; | |||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 2 | my %args = @{$c->req->arguments}; | |||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | $c->stash->{navi} = [ | ||||||||||||||||||||||||||||
| 124 | { | ||||||||||||||||||||||||||||
| 125 | 2 | title => "reports by suite", | |||||||||||||||||||||||||||
| 126 | href => "/tapper/overview/suite", | ||||||||||||||||||||||||||||
| 127 | }, | ||||||||||||||||||||||||||||
| 128 | { | ||||||||||||||||||||||||||||
| 129 | title => "reports by host", | ||||||||||||||||||||||||||||
| 130 | href => "/tapper/overview/host", | ||||||||||||||||||||||||||||
| 131 | }, | ||||||||||||||||||||||||||||
| 132 | { | ||||||||||||||||||||||||||||
| 133 | title => "This list as RSS", | ||||||||||||||||||||||||||||
| 134 | href => "/tapper/rss/".$self->prepare_filter_path($c), | ||||||||||||||||||||||||||||
| 135 | image => "/tapper/static/images/rss.png", | ||||||||||||||||||||||||||||
| 136 | }, | ||||||||||||||||||||||||||||
| 137 | { | ||||||||||||||||||||||||||||
| 138 | title => "reports by people", | ||||||||||||||||||||||||||||
| 139 | href => "/tapper/reports/people/", | ||||||||||||||||||||||||||||
| 140 | active => 0, | ||||||||||||||||||||||||||||
| 141 | }, | ||||||||||||||||||||||||||||
| 142 | ]; | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | 2 | my @a_subnavi; | |||||||||||||||||||||||||||
| 145 | 2 | my @a_args = @{$c->req->arguments}; | |||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | 2 | ▶ | OUTER: for ( my $i = 0; $i < @a_args; $i+=2 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 148 | 0 | my $s_reduced_filter_path = q##; | |||||||||||||||||||||||||||
| 149 | 0 | ▶ | for ( my $j = 0; $j < @a_args; $j+=2 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 150 | 0 | ▶ | next if $i == $j; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 151 | 0 | $s_reduced_filter_path .= "/$a_args[$j]/" . $a_args[$j+1]; | |||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||
| 153 | push @a_subnavi, { | ||||||||||||||||||||||||||||
| 154 | title => "$a_args[$i]: ".$a_args[$i+1], | ||||||||||||||||||||||||||||
| 155 | href => '/tapper/reports' | ||||||||||||||||||||||||||||
| 156 | . $s_reduced_filter_path | ||||||||||||||||||||||||||||
| 157 | . '?report_date=' | ||||||||||||||||||||||||||||
| 158 | . $c->stash->{report_date}->strftime('%F') | ||||||||||||||||||||||||||||
| 159 | . '&pager_interval=' | ||||||||||||||||||||||||||||
| 160 | . $c->stash->{pager_interval}, | ||||||||||||||||||||||||||||
| 161 | 0 | image => '/tapper/static/images/minus.png', | |||||||||||||||||||||||||||
| 162 | }; | ||||||||||||||||||||||||||||
| 163 | } # OUTER | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 2 | push @{$c->stash->{navi}}, | |||||||||||||||||||||||||||
| 166 | { title => 'Active Filters', subnavi => \@a_subnavi, }, | ||||||||||||||||||||||||||||
| 167 | { title => 'New Filters', id => 'idx_new_filter' }, | ||||||||||||||||||||||||||||
| 168 | { title => 'Help', id => 'idx_help', subnavi => [{ title => 'Press Shift for multiple Filters' }] }, | ||||||||||||||||||||||||||||
| 169 | ; | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 14 | ▶ | } | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | 14 | 1; | |||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | __END__ | ||||||||||||||||||||||||||||