blib/lib/Tapper/Reports/Web/Controller/Tapper/Metareports.pm

filter: Statementstmt 12.8% 86 / 668 Branchbran 0.0% 0 / 178 Conditioncond 0.0% 0 / 85 MC/DCmcdc 0.0% 0 / 51 Subroutinesub 41.1% 28 / 68 Podpod 0.0% 0 / 23 totaltotal 10.6% 114 / 1073 CC 164 SCAR 81.1
CC
164
Cov
9%
get_chart_points
8372.0
insert_chart
272.0
get_edit_page_chart_hash_by_params
110.0
CRAP 3329.8
↑ Summary blib/lib/Tapper/Reports/Web/Util/Report.pm »
1 package Tapper::Reports::Web::Controller::Tapper::Metareports;
2 13 our $AUTHORITY = 'cpan:TAPPER';
3 13 $Tapper::Reports::Web::Controller::Tapper::Metareports::VERSION = '5.0.17';
4 # ABSTRACT: Tapper - Catalyst Controller Metareports
5  
6 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 13 ▶use parent 'Tapper::Reports::Web::Controller::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 13 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 13 ▶use List::MoreUtils qw( any );
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 13 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 0 ▶sub index :Path :Args() {
Subroutine index: not called CC=1 SCAR=6.9
16  
17 0 my ( $self, $c, @args ) = @_;
18  
19 0 $c->go('/tapper/metareports/chart_overview');
20  
21 13 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 0 ▶sub auto : Private {
Subroutine auto: not called CC=1 SCAR=6.9
Pod undocumented
24  
25 0 my ( $self, $or_c ) = @_;
26  
27 # set js, csss file
28 0 push @{$or_c->stash->{js_files}}, '/tapper/static/js/metareports.js';
29 0 push @{$or_c->stash->{css_files}}, '/tapper/static/css/metareports/default.css';
30  
31 0 $or_c->forward('/tapper/metareports/prepare_navi');
32 13 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
33  
34 0 ▶sub hr_get_search : Private {
Subroutine hr_get_search: not called CC=4 SCAR=30.0
Pod undocumented
35  
36 0 my ( $or_schema, $hr_params ) = @_;
37  
38 0 my ( $hr_search, $ar_join ) = ({},[]);
39 0 ▶ if ( $hr_params->{chart_tiny_url} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($hr_params->{'chart_tiny_url'}) { } 0 0 0
elsif ($hr_params->{'chart_id'}) { } 0 0 0
40 0 $hr_search->{chart_tiny_url_id} = $hr_params->{chart_tiny_url};
41 0 push @{$ar_join}, { 'chart_lines' => 'chart_tiny_url_lines' };
42 }
43 elsif ( $hr_params->{chart_id} ) {
44 0 ▶ if (! $hr_params->{chart_version} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($hr_params->{"chart_version"}) 0 0 0
45 $hr_params->{chart_version} = $or_schema->resultset('ChartVersions')
46 ->search({
47 chart_id => $hr_params->{chart_id}
48 })
49 0 ->get_column('chart_version')
50 ->max();
51 }
52 0 $hr_search->{'me.chart_id'} = $hr_params->{chart_id} ;
53 0 $hr_search->{'me.chart_version'} = $hr_params->{chart_version};
54 }
55 else {
56 0 return;
57 }
58  
59 0 return ( $hr_search, $ar_join );
60  
61 13 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
62  
63 0 ▶sub detail : Local {
Subroutine detail: not called CC=8 SCAR=42.8
Pod undocumented
64  
65 0 my ( $or_self, $or_c ) = @_;
66  
67 0 $or_c->stash->{head_overview} = 'Metareports - Detail';
68  
69 # set css file
70 0 push @{$or_c->stash->{css_files}},
71 '/tapper/static/css/metareports/detail.css',
72 , '/tapper/static/css/jquery-ui/jquery.ui.css'
73 , '/tapper/static/css/jquery-ui/jquery.ui.core.css'
74 , '/tapper/static/css/jquery-ui/jquery.ui.datepicker.css'
75 ;
76  
77 # set js file
78 0 push @{$or_c->stash->{js_files}},
79 '/tapper/static/js/jquery-ui/jquery.ui.core.js'
80 , '/tapper/static/js/jquery-ui/jquery.ui.effect.js'
81 , '/tapper/static/js/jquery-ui/jquery.ui.datepicker.js'
82 , '/tapper/static/js/jquery-ui/jquery.ui.effect-slide.js'
83 , '/tapper/static/js/metareports.js'
84 , '/tapper/static/js/jquery-plugins/jquery.json.js'
85 , '/tapper/static/js/jquery-plugins/jquery.flot.js'
86 , '/tapper/static/js/jquery-plugins/jquery.flot.time.js'
87 , '/tapper/static/js/jquery-plugins/jquery.flot.selection.js'
88 , '/tapper/static/js/jquery-plugins/jquery.timepicker.js'
89 ;
90  
91 0 my $hr_params = $or_c->req->params;
92 0 my $or_schema = $or_c->model('TestrunDB');
93  
94 0 my ( $hr_search, $ar_join ) = hr_get_search( $or_schema, $hr_params );
95 0 ▶ if ( $hr_search ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hr_search) 0 0 0
96  
97 0 $or_c->stash->{chart} = $or_schema
98 ->resultset('ChartVersions')
99 ->search(
100 $hr_search,
101 {
102 join => $ar_join,
103 prefetch => [
104 {
105 'chart_lines' => {
106 'chart_line_restrictions' => 'chart_line_restriction_values',
107 },
108 },{
109 'chart' => [
110 'chart_versions',
111 { 'chart_tag_relations' => 'chart_tag', },
112 ],
113 },
114 ],
115 }
116 )
117 ->first()
118 ;
119  
120 # check for template parameter
121 0 my %h_restriction_values;
122 0 ▶ for my $or_chart_line ( $or_c->stash->{chart} ? $or_c->stash->{chart}->chart_lines : () ) {
Branch: 1 branch
BranchTrueFalseTotal
$or_c->stash->{'chart'} ? : 0 0 0
123 0 for my $or_restriction ( $or_chart_line->chart_line_restrictions ) {
124 0 ▶ if ( $or_restriction->is_template_restriction ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($or_restriction->is_template_restriction) 0 0 0
125 0 my $s_restricted_value =
126 ($or_restriction->chart_line_restriction_values)[0]->chart_line_restriction_value
127 ;
128 0 ▶ if ( $hr_params->{$s_restricted_value} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hr_params->{$s_restricted_value}) { } 0 0 0
129 0 $h_restriction_values{$s_restricted_value} = $hr_params->{$s_restricted_value};
130 }
131 else {
132 0 $or_c->stash->{error} = "Missing restricted value '$s_restricted_value'";
133 }
134 }
135 }
136 }
137 0 ▶ if ( %h_restriction_values ) {
Branch: 1 branch
BranchTrueFalseTotal
if (%h_restriction_values) 0 0 0
138 0 $or_c->stash->{parameter_restriction_values} = \%h_restriction_values;
139 }
140  
141 }
142  
143 0 return 1;
144  
145 13 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
146  
147 0 ▶sub chart_overview : Local {
Subroutine chart_overview: not called CC=3 SCAR=24.8
Pod undocumented
148  
149 0 my ( $or_self, $or_c ) = @_;
150  
151 # set css file
152 0 push @{$or_c->stash->{css_files}},
153 '/tapper/static/css/metareports/chart_overview.css'
154 ;
155  
156 # set js file
157 0 push @{$or_c->stash->{js_files}},
158 '/tapper/static/js/metareports.js'
159 , '/tapper/static/js/jquery-plugins/jquery.flot.js'
160 , '/tapper/static/js/jquery-plugins/jquery.flot.time.js'
161 ;
162  
163 0 my $hr_where = {
164 'me.active' => 1,
165 'chart_versions.chart_version' => \" = (
166 SELECT MAX(cv.chart_version)
167 FROM chart_versions cv
168 WHERE cv.chart_id = chart_versions.chart_id
169 )",
170 };
171 0 my $hr_options = {
172 order_by => {
173 -asc => 'chart_versions.chart_name'
174 },
175 join => [
176 {
177 'chart_versions' => {
178 'chart_lines' => {
179 'chart_line_restrictions' => 'chart_line_restriction_values',
180 },
181 },
182 },
183 ],
184 prefetch => {
185 'chart_versions' => {
186 'chart_lines' => {
187 'chart_line_restrictions' => 'chart_line_restriction_values',
188 },
189 },
190 },
191 };
192  
193 0 my $i_chart_tag = $or_c->req->params->{chart_tag};
194 0 ▶ if ( defined($i_chart_tag) && $i_chart_tag ne '0' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $i_chart_tag and $i_chart_tag ne 0) 0 0 0
Condition0%0/3
defined $i_chart_tag and $i_chart_tag ne 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $i_chart_tag and $i_chart_tag ne 0
defined $i_chart_tag $i_chart_tag ne 0
Truth table0%0/3
A and B
A= defined $i_chart_tagB= $i_chart_tag ne 0
ABresult
0X0
100
111
195 0 $hr_where->{'chart_tag_relations.chart_tag_id'} = $i_chart_tag;
196 0 push @{$hr_options->{join}}, 'chart_tag_relations';
197 }
198  
199 0 $or_c->stash->{head_overview} = 'Metareports - Overview';
200 $or_c->stash->{charts} = [
201 0 $or_c->model('TestrunDB')->resultset('Charts')->search(
202 $hr_where, $hr_options,
203 )
204 ];
205  
206 0 return 1;
207  
208 13 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
209  
210 0 ▶sub get_chart_points : Local {
Subroutine get_chart_points: not called CC=91 SCAR=90.3
Pod undocumented
211  
212 0 my ( $or_self, $or_c ) = @_;
213  
214 0 my %h_params = %{$or_c->req->params};
215 0 my $or_schema = $or_c->model('TestrunDB');
216  
217 # get chart information
218 0 my ( $hr_search, $ar_join ) = hr_get_search( $or_schema, \%h_params );
219 0 ▶ if (! $hr_search ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($hr_search) 0 0 0
220 0 $or_c->res->status( 500 );
221 0 $or_c->stash->{content} = { error => 'cannot create search condition' };
222 }
223  
224 0 my $or_chart = $or_schema->resultset('ChartVersions')->search(
225 $hr_search,
226 {
227 join => $ar_join,
228 prefetch => [
229 {
230 'chart_lines' => [
231 'chart_additionals',
232 {
233 'chart_line_restrictions' => 'chart_line_restriction_values',
234 },
235 {
236 'chart_axis_elements' => [
237 'axis_column',
238 'axis_separator',
239 ],
240 },
241 ],
242 },
243 'chart_markings',
244 'chart_axis_type_x',
245 'chart_axis_type_y',
246 'chart_type',
247 ],
248 }
249 )->first();
250  
251 0 my %h_axis = ( x => {}, y => {}, );
252 0 my ( @a_first, @a_last, @a_result, @a_markings, @a_chart_line_point_warnings );
253  
254 # update tiny url counter if exists
255 0 my $or_tiny_url;
256 0 my $NOW = DateTime->now();
257 0 ▶ if ( my $i_chart_tiny_url_id = $h_params{chart_tiny_url} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $i_chart_tiny_url_id = $h_params{"chart_tiny_url"}) 0 0 0
258 0 $or_tiny_url = $or_schema
259 ->resultset('ChartTinyUrls')
260 ->search({
261 'me.chart_tiny_url_id' => $i_chart_tiny_url_id,
262 },{
263 rows => 1,
264 prefetch => {
265 chart_tiny_url_line => 'chart_tiny_url_relation'
266 },
267 })
268 ->first()
269 ;
270 0 ▶ if ($or_tiny_url) {
Branch: 1 branch
BranchTrueFalseTotal
if ($or_tiny_url) 0 0 0
271 0 $or_tiny_url->visit_count( $or_tiny_url->visit_count() + 1 );
272 0 $or_tiny_url->last_visited($NOW);
273 0 $or_tiny_url->update();
274 0 $or_c->stash->{tiny_url_count} = $or_tiny_url->visit_count;
275 }
276 }
277  
278 0 ▶ if ( my @a_chart_lines = $or_chart->chart_lines ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@a_chart_lines) = $or_chart->chart_lines) 0 0 0
279  
280 0 require JSON::XS;
281 0 require YAML::Syck;
282 0 require Tapper::Config;
283 0 require BenchmarkAnything::Storage::Frontend::Lib;
284  
285 my $balib = BenchmarkAnything::Storage::Frontend::Lib->new
286 0 (cfgfile => Tapper::Config->subconfig->{_last_used_tapper_config_file});
287  
288 0 require DateTime;
289 0 require DateTime::Format::Epoch;
290 0 require DateTime::Format::Strptime;
291 0 my $formatter = DateTime::Format::Epoch->new(
292 epoch => DateTime->new( year => 1970, month => 1, day => 1 ),
293 unit => 'milliseconds',
294 type => 'int', # or 'float', 'bigint'
295 skip_leap_seconds => 1,
296 start_at => 0,
297 local_epoch => undef,
298 );
299  
300 0 my %h_counter = (
301 x => 0 ,
302 y => 0,
303 );
304 0 my %h_axis_type = (
305 x => $or_chart->chart_axis_type_x->chart_axis_type_name,
306 y => $or_chart->chart_axis_type_y->chart_axis_type_name,
307 );
308 my %h_label_type = (
309 x => $h_axis_type{x} eq 'alphanumeric' || $or_chart->order_by_x_axis == 2 && $or_chart->order_by_y_axis == 1 ? 'list' : 'auto',
310 0 ▶ y => $h_axis_type{y} eq 'alphanumeric' || $or_chart->order_by_y_axis == 2 && $or_chart->order_by_x_axis == 1 ? 'list' : 'auto',
Branch: 2 branches
BranchTrueFalseTotal
$h_axis_type{'x'} eq 'alphanumeric' || $or_chart->order_by_x_axis == 2 && $or_chart->order_by_y_axis == 1 ? : 0 0 0
$h_axis_type{'y'} eq 'alphanumeric' || $or_chart->order_by_y_axis == 2 && $or_chart->order_by_x_axis == 1 ? : 0 0 0
Condition0%0/12
$h_axis_type{"x"} eq "alphanumeric" or $or_chart->order_by_x_axis == 2 and $or_chart->order_by_y_axis == 1
l!l&&r!l&&!r
000
$or_chart->order_by_x_axis == 2 and $or_chart->order_by_y_axis == 1
!ll&&!rl&&r
000
$h_axis_type{"y"} eq "alphanumeric" or $or_chart->order_by_y_axis == 2 and $or_chart->order_by_x_axis == 1
l!l&&r!l&&!r
000
$or_chart->order_by_y_axis == 2 and $or_chart->order_by_x_axis == 1
!ll&&!rl&&r
000
MC/DC0%0/3
$h_axis_type{"x"} eq "alphanumeric" or $or_chart->order_by_x_axis == 2 and $or_chart->order_by_y_axis == 1
$h_axis_type{"x"} eq "alphanumeric" $or_chart->order_by_x_axis == 2 $or_chart->order_by_y_axis == 1
MC/DC0%0/3
$h_axis_type{"y"} eq "alphanumeric" or $or_chart->order_by_y_axis == 2 and $or_chart->order_by_x_axis == 1
$h_axis_type{"y"} eq "alphanumeric" $or_chart->order_by_y_axis == 2 $or_chart->order_by_x_axis == 1
Truth table0%0/4
A or B and C
A= $h_axis_type{"x"} eq "alphanumeric"B= $or_chart->order_by_x_axis == 2C= $or_chart->order_by_y_axis == 1
ABCresult
1XX1
0111
00X0
0100
Truth table0%0/4
A or B and C
A= $h_axis_type{"y"} eq "alphanumeric"B= $or_chart->order_by_y_axis == 2C= $or_chart->order_by_x_axis == 1
ABCresult
1XX1
0111
00X0
0100
311 );
312  
313 0 ▶ $h_params{limit} ||= $h_params{graph_width} ? int( $h_params{graph_width} / 4 ) : 100;
Branch: 1 branch
BranchTrueFalseTotal
$h_params{'graph_width'} ? : 0 0 0
Condition0%0/3
$h_params{"limit"} ||= $h_params{"graph_width"} ? int $h_params{"graph_width"} / 4 : 100
l!l&&r!l&&!r
000
MC/DC0%0/2
$h_params{"limit"} ||= $h_params{"graph_width"} ? int $h_params{"graph_width"} / 4 : 100
$h_params{"limit"} $h_params{"graph_width"} ? int $h_params{"graph_width"} / 4 : 100
Truth table0%0/3
A ||= B
A= $h_params{"limit"}B= $h_params{"graph_width"} ? int $h_params{"graph_width"} / 4 : 100
ABresult
1X1
011
000
314  
315 0 ▶ if ( $h_params{pager_direction} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($h_params{'pager_direction'}) { } 0 0 0
316 0 ▶ if ( $h_params{pager_direction} eq 'prev' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($h_params{'pager_direction'} eq 'prev') { } 0 0 0
317 0 $h_params{offset} = $h_params{offset};
318 }
319 else {
320 0 $h_params{offset} = $h_params{offset} - ( $h_params{limit} * 2 );
321 }
322 }
323 else {
324 0 $h_params{offset} = 0;
325 }
326  
327 0 CHART_LINE: for my $or_chart_line ( @a_chart_lines ) {
328  
329 0 my @a_additionals;
330 0 my $b_value_id_exists = 0;
331 0 for my $or_additional_column ( $or_chart_line->chart_additionals ) {
332 0 ▶ if ( $or_additional_column->chart_line_additional_column eq 'VALUE_ID' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($or_additional_column->chart_line_additional_column eq "VALUE_ID") 0 0 0
333 0 $b_value_id_exists = 1;
334 }
335 0 push @a_additionals, [
336 $or_additional_column->chart_line_additional_column,
337 $or_additional_column->chart_line_additional_url,
338 ];
339 }
340 0 ▶ if ( !$b_value_id_exists ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($b_value_id_exists) 0 0 0
341 0 unshift @a_additionals, ['VALUE_ID'];
342 }
343  
344 0 my $hr_chart_search = {};
345 0 $hr_chart_search->{limit} = $h_params{limit};
346 0 $hr_chart_search->{offset} = $h_params{offset};
347  
348 0 for my $s_axis (qw/ x y /) {
349 0 for my $or_element ( sort { $a->chart_line_axis_element_number <=> $b->chart_line_axis_element_number } $or_chart_line->chart_axis_elements ) {
350 0 ▶ if ( $or_element->chart_line_axis eq $s_axis && $or_element->axis_column ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($or_element->chart_line_axis eq $s_axis and $or_element->axis_column) 0 0 0
Condition0%0/3
$or_element->chart_line_axis eq $s_axis and $or_element->axis_column
!ll&&!rl&&r
000
MC/DC0%0/2
$or_element->chart_line_axis eq $s_axis and $or_element->axis_column
$or_element->chart_line_axis eq $s_axis $or_element->axis_column
Truth table0%0/3
A and B
A= $or_element->chart_line_axis eq $s_axisB= $or_element->axis_column
ABresult
0X0
100
111
351 0 push @{$hr_chart_search->{order_by}}, [
352 $or_element->axis_column->chart_line_axis_column,
353 'DESC',
354 0 { numeric => $h_axis_type{$s_axis} eq 'numeric' },
355 ];
356 }
357 }
358 }
359  
360 0 my @a_chart_line_points;
361 LOADING_DATA: {
362  
363 # set where clause with bench_value_id for tiny url
364 0 ▶ if ( $or_tiny_url ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($or_tiny_url) { } 0 0 0
elsif ($or_chart_line->chart_line_restrictions) { } 0 0 0
365 0 my $or_chart_tiny_url_line;
366 0 for my $or_act_line ( $or_tiny_url->chart_tiny_url_line ) {
367 0 ▶ if ( $or_act_line->chart_line_id == $or_chart_line->chart_line_id ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($or_act_line->chart_line_id == $or_chart_line->chart_line_id) 0 0 0
368 0 $or_chart_tiny_url_line = $or_act_line;
369 }
370 }
371 0 my @a_bench_value_ids = $or_chart_tiny_url_line
372 ->chart_tiny_url_relation
373 ->get_column('bench_value_id')
374 ->all
375 ;
376 0 ▶ if ( @a_bench_value_ids ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@a_bench_value_ids) { } 0 0 0
377 $hr_chart_search->{where} = [[
378 0 '=',
379 'VALUE_ID',
380 @a_bench_value_ids,
381 ]];
382 }
383 else {
384 0 last LOADING_DATA;
385 }
386 }
387 # set where clause
388 elsif ( $or_chart_line->chart_line_restrictions ) {
389 0 ▶ $hr_chart_search->{where} ||= [];
Condition0%0/2
$hr_chart_search->{"where"} ||= []
l!l
00
MC/DC0%0/1
$hr_chart_search->{"where"} ||= []
$hr_chart_search->{"where"}
Truth table0%0/2
A
A= $hr_chart_search->{"where"}
Aresult
11
00
390 0 for my $or_chart_line_restriction ( $or_chart_line->chart_line_restrictions ) {
391 0 my @a_chart_line_restriction_value;
392 0 ▶ if ( $or_chart_line_restriction->is_template_restriction ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($or_chart_line_restriction->is_template_restriction) { } 0 0 0
393 0 my ( $s_restriction_value_identifier )
394 = ($or_chart_line_restriction->chart_line_restriction_values)[0]->chart_line_restriction_value
395 ;
396 0 ▶ if ( defined $h_params{$s_restriction_value_identifier} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $h_params{$s_restriction_value_identifier}) { } 0 0 0
397 0 @a_chart_line_restriction_value = @{toarrayref( $h_params{$s_restriction_value_identifier} )};
398 }
399 else {
400 $or_c->stash->{content} = {
401 0 error => "missing template parameter '$s_restriction_value_identifier'",
402 };
403 0 return 0;
404 }
405 }
406 else {
407 @a_chart_line_restriction_value = map {
408 0 $_->chart_line_restriction_value
409 } $or_chart_line_restriction->chart_line_restriction_values;
410 }
411 0 push @{$hr_chart_search->{where}}, [
412 $or_chart_line_restriction->chart_line_restriction_operator,
413 $or_chart_line_restriction->chart_line_restriction_column,
414 @a_chart_line_restriction_value,
415 ];
416 }
417 }
418 else {
419 0 last LOADING_DATA;
420 }
421  
422 # set select columns
423 0 my %h_chart_search_select = map { $_ => 1 }
424 (
425 0 map { $_->axis_column->chart_line_axis_column }
426 0 grep { $_->axis_column }
427 $or_chart_line->chart_axis_elements
428 ), (
429 0 map { $_->[0] } @a_additionals
430 );
431 $hr_chart_search->{select} = [
432 0 keys %h_chart_search_select
433 ];
434  
435 0 my $ar_chart_points = $balib->search( $hr_chart_search );
436  
437 0 ▶ if ( $ar_chart_points && @{$ar_chart_points} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ar_chart_points and @{$ar_chart_points;}) 0 0 0
Condition0%0/3
$ar_chart_points and @{$ar_chart_points;}
!ll&&!rl&&r
000
MC/DC0%0/2
$ar_chart_points and @{$ar_chart_points;}
$ar_chart_points @{$ar_chart_points;}
Truth table0%0/3
A and B
A= $ar_chart_pointsB= @{$ar_chart_points;}
ABresult
0X0
100
111
438  
439 0 for my $or_element ( sort { $a->chart_line_axis_element_number <=> $b->chart_line_axis_element_number } $or_chart_line->chart_axis_elements ) {
440 0 ▶ if ( $or_element->axis_column ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($or_element->axis_column) 0 0 0
441 0 push @a_first, [ $or_element->axis_column->chart_line_axis_column, $ar_chart_points->[-1]{$or_element->axis_column->chart_line_axis_column} ];
442 0 push @a_last , [ $or_element->axis_column->chart_line_axis_column, $ar_chart_points->[ 0]{$or_element->axis_column->chart_line_axis_column} ];
443 }
444 }
445  
446 0 for my $hr_point ( @{$ar_chart_points} ) {
447  
448 0 eval {
449  
450 0 my $hr_chart_point = { x => q##, y => q##, additionals => {} };
451 0 for my $or_element ( sort { $a->chart_line_axis_element_number <=> $b->chart_line_axis_element_number } $or_chart_line->chart_axis_elements ) {
452 0 ▶ if ( $or_element->axis_column ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($or_element->axis_column) { } 0 0 0
453 0 ▶ if ( defined $hr_point->{$or_element->axis_column->chart_line_axis_column} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $$hr_point{$or_element->axis_column->chart_line_axis_column}) { } 0 0 0
454 0 $hr_chart_point->{$or_element->chart_line_axis} .= $hr_point->{$or_element->axis_column->chart_line_axis_column};
455 }
456 else {
457 0 die 'missing value for ' . $or_element->chart_line_axis . "-axis\n";
458 }
459 }
460 else {
461 0 $hr_chart_point->{$or_element->chart_line_axis} .= $or_element->axis_separator->chart_line_axis_separator;
462 }
463 }
464  
465 0 my ( %h_strp );
466 0 ▶ if ( $or_chart->chart_axis_type_x->chart_axis_type_name eq 'date' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($or_chart->chart_axis_type_x->chart_axis_type_name eq "date") 0 0 0
467 0 ▶ if ( my $dt_format = $or_chart_line->chart_axis_x_column_format ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $dt_format = $or_chart_line->chart_axis_x_column_format) { } 0 0 0
468 0 require DateTime::Format::Strptime;
469 0 $h_strp{x} = DateTime::Format::Strptime->new( pattern => $dt_format );
470 }
471 else {
472 0 $or_c->response->status( 500 );
473 0 $or_c->body('xaxis type is date but no date format is given for "' . $or_chart_line->chart_line_name . '"');
474 0 return 1;
475 }
476 }
477 0 ▶ if ( $or_chart->chart_axis_type_y->chart_axis_type_name eq 'date' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($or_chart->chart_axis_type_y->chart_axis_type_name eq "date") 0 0 0
478 0 ▶ if ( my $dt_format = $or_chart_line->chart_axis_y_column_format ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $dt_format = $or_chart_line->chart_axis_y_column_format) { } 0 0 0
479 0 require DateTime::Format::Strptime;
480 0 $h_strp{y} = DateTime::Format::Strptime->new( pattern => $dt_format );
481 }
482 else {
483 0 $or_c->response->status( 500 );
484 0 $or_c->body('yaxis type is date but no date format is given for "' . $or_chart_line->chart_line_name . '"');
485 0 return 1;
486 }
487 }
488  
489 0 for my $s_axis (qw/ x y /) {
490 0 $hr_chart_point->{$s_axis.'o'} = $hr_chart_point->{$s_axis};
491 0 ▶ if ( $h_strp{$s_axis} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($h_strp{$s_axis}) 0 0 0
492 $hr_chart_point->{$s_axis} = $formatter->format_datetime(
493 0 $h_strp{$s_axis}->parse_datetime( $hr_chart_point->{$s_axis.'o'} )
494 );
495 }
496 }
497  
498 0 ▶ if ( $or_chart->order_by_x_axis == 1 && $or_chart->order_by_y_axis == 2 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($or_chart->order_by_x_axis == 1 and $or_chart->order_by_y_axis == 2) { } 0 0 0
elsif ($or_chart->order_by_x_axis == 2 and $or_chart->order_by_y_axis == 1) { } 0 0 0
Condition0%0/3
$or_chart->order_by_x_axis == 1 and $or_chart->order_by_y_axis == 2
!ll&&!rl&&r
000
MC/DC0%0/2
$or_chart->order_by_x_axis == 1 and $or_chart->order_by_y_axis == 2
$or_chart->order_by_x_axis == 1 $or_chart->order_by_y_axis == 2
Truth table0%0/3
A and B
A= $or_chart->order_by_x_axis == 1B= $or_chart->order_by_y_axis == 2
ABresult
0X0
100
111
499 0 $hr_chart_point->{'yh'} = $hr_chart_point->{'x'}.'|-|'.$hr_chart_point->{'y'};
500 }
501 ▶ elsif ( $or_chart->order_by_x_axis == 2 && $or_chart->order_by_y_axis == 1 ) {
Condition0%0/3
$or_chart->order_by_x_axis == 2 and $or_chart->order_by_y_axis == 1
!ll&&!rl&&r
000
MC/DC0%0/2
$or_chart->order_by_x_axis == 2 and $or_chart->order_by_y_axis == 1
$or_chart->order_by_x_axis == 2 $or_chart->order_by_y_axis == 1
Truth table0%0/3
A and B
A= $or_chart->order_by_x_axis == 2B= $or_chart->order_by_y_axis == 1
ABresult
0X0
100
111
502 0 $hr_chart_point->{'xh'} = $hr_chart_point->{'y'}.'|-|'.$hr_chart_point->{'x'};
503 }
504  
505 0 for my $s_axis (qw/ x y /) {
506 0 ▶ if ( $h_label_type{$s_axis} eq 'list' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($h_label_type{$s_axis} eq "list") 0 0 0
507 0 ▶ $hr_chart_point->{$s_axis.'h'} //= $hr_chart_point->{$s_axis.'o'};
Condition0%0/3
$$hr_chart_point{$s_axis . 'h'} //= $$hr_chart_point{$s_axis . 'o'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$$hr_chart_point{$s_axis . 'h'} //= $$hr_chart_point{$s_axis . 'o'}
$$hr_chart_point{$s_axis . 'h'} $$hr_chart_point{$s_axis . 'o'}
Truth table0%0/3
A //= B
A= $$hr_chart_point{$s_axis . 'h'}B= $$hr_chart_point{$s_axis . 'o'}
ABresult
1X1
011
000
508 0 ▶ $hr_chart_point->{$s_axis} = $h_axis{$s_axis}{$hr_chart_point->{$s_axis.'h'}} //= $h_counter{$s_axis}++;
Condition0%0/2
$h_axis{$s_axis}{$$hr_chart_point{$s_axis . 'h'}} //= $h_counter{$s_axis}++
l!l
00
MC/DC0%0/1
$h_axis{$s_axis}{$$hr_chart_point{$s_axis . 'h'}} //= $h_counter{$s_axis}++
$h_axis{$s_axis}{$$hr_chart_point{$s_axis . 'h'}}
Truth table0%0/2
A
A= $h_axis{$s_axis}{$$hr_chart_point{$s_axis . 'h'}}
Aresult
11
00
509 }
510 }
511  
512 0 for my $ar_chart_line_addition ( @a_additionals ) {
513 $hr_chart_point->{additionals}{$ar_chart_line_addition->[0]} = [
514 0 $hr_point->{$ar_chart_line_addition->[0]},
515 ];
516 0 ▶ if ( $ar_chart_line_addition->[1] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ar_chart_line_addition->[1]) 0 0 0
517 0 $hr_chart_point->{additionals}{$ar_chart_line_addition->[0]}[1] =
518 $ar_chart_line_addition->[1];
519 }
520 }
521  
522 0 ▶ if (( defined $hr_chart_point->{x} ) && ( defined $hr_chart_point->{y} )) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $hr_chart_point->{"x"} and defined $hr_chart_point->{"y"}) 0 0 0
Condition0%0/3
defined $hr_chart_point->{"x"} and defined $hr_chart_point->{"y"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $hr_chart_point->{"x"} and defined $hr_chart_point->{"y"}
defined $hr_chart_point->{"x"} defined $hr_chart_point->{"y"}
Truth table0%0/3
A and B
A= defined $hr_chart_point->{"x"}B= defined $hr_chart_point->{"y"}
ABresult
0X0
100
111
523 0 push @a_chart_line_points, $hr_chart_point;
524 }
525  
526 };
527 0 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
528 0 push @a_chart_line_point_warnings, $@;
529 }
530  
531 }
532  
533 }
534  
535 } # LOADING_DATA
536  
537 0 push @a_result, {
538 data => \@a_chart_line_points,
539 label => $or_chart_line->chart_line_name,
540 chart_line_id => $or_chart_line->chart_line_id,
541 };
542  
543 }
544  
545 my %h_sort_function = (
546 0 ▶ date => sub { $_[0] <=> $_[1] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
547 0 ▶ numeric => sub { $_[0] <=> $_[1] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
548 0 ▶ alphanumeric => sub { $_[0] cmp $_[1] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
549 0 );
550  
551 0 ▶ $h_sort_function{x_first_array} = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
552 $h_sort_function{$h_axis_type{x}}->( $_[0]->[0], $_[1]->[0] )
553 0 ▶ || $h_sort_function{$h_axis_type{y}}->( $_[0]->[1], $_[1]->[1] )
Branch: 1 branch
BranchTrueFalseTotal
$h_sort_function{$h_axis_type{"x"}}($_[0][0], $_[1][0]) or $h_sort_function{$h_axis_type{"y"}}($_[0][1], $_[1][1]) 0 0 0
554 0 };
555 0 ▶ $h_sort_function{y_first_array} = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
556 $h_sort_function{$h_axis_type{y}}->( $_[0]->[0], $_[1]->[0] )
557 0 ▶ || $h_sort_function{$h_axis_type{x}}->( $_[0]->[1], $_[1]->[1] )
Branch: 1 branch
BranchTrueFalseTotal
$h_sort_function{$h_axis_type{"y"}}($_[0][0], $_[1][0]) or $h_sort_function{$h_axis_type{"x"}}($_[0][1], $_[1][1]) 0 0 0
558 0 };
559 0 ▶ $h_sort_function{x_first_hash} = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
560 $_[0]->{x} <=> $_[1]->{x}
561 || $_[0]->{y} <=> $_[1]->{y}
562 0 ▶ };
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{"x"} <=> $_[1]{"x"} or $_[0]{"y"} <=> $_[1]{"y"} 0 0 0
563 0 ▶ $h_sort_function{y_first_hash} = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
564 $_[0]->{y} <=> $_[1]->{y}
565 || $_[0]->{x} <=> $_[1]->{x}
566 0 ▶ };
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{"y"} <=> $_[1]{"y"} or $_[0]{"x"} <=> $_[1]{"x"} 0 0 0
567  
568 # sortiere die Labels
569 0 ▶ if ( $h_label_type{x} eq 'list' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($h_label_type{"x"} eq "list") 0 0 0
570 0 my $i_counter = 0;
571 0 ▶ if ( $or_chart->order_by_x_axis == 2 && $or_chart->order_by_y_axis == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($or_chart->order_by_x_axis == 2 and $or_chart->order_by_y_axis == 1) { } 0 0 0
Condition0%0/3
$or_chart->order_by_x_axis == 2 and $or_chart->order_by_y_axis == 1
!ll&&!rl&&r
000
MC/DC0%0/2
$or_chart->order_by_x_axis == 2 and $or_chart->order_by_y_axis == 1
$or_chart->order_by_x_axis == 2 $or_chart->order_by_y_axis == 1
Truth table0%0/3
A and B
A= $or_chart->order_by_x_axis == 2B= $or_chart->order_by_y_axis == 1
ABresult
0X0
100
111
572 0 for my $ar_key ( sort { $h_sort_function{'y_first_array'}->( $a, $b ) } map {[split /\|-\|/, $_]} keys %{$h_axis{x}} ) {
573 0 $h_axis{x}{join '|-|', @{$ar_key}} = $i_counter++;
574 }
575 }
576 else {
577 0 for my $s_key ( sort { $h_sort_function{$h_axis_type{x}}->( $a, $b ) } keys %{$h_axis{x}} ) {
578 0 $h_axis{x}{$s_key} = $i_counter++;
579 }
580 }
581 }
582 0 ▶ if ( $h_label_type{y} eq 'list' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($h_label_type{"y"} eq "list") 0 0 0
583 0 my $i_counter = 0;
584 0 ▶ if ( $or_chart->order_by_x_axis == 1 && $or_chart->order_by_y_axis == 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($or_chart->order_by_x_axis == 1 and $or_chart->order_by_y_axis == 2) { } 0 0 0
Condition0%0/3
$or_chart->order_by_x_axis == 1 and $or_chart->order_by_y_axis == 2
!ll&&!rl&&r
000
MC/DC0%0/2
$or_chart->order_by_x_axis == 1 and $or_chart->order_by_y_axis == 2
$or_chart->order_by_x_axis == 1 $or_chart->order_by_y_axis == 2
Truth table0%0/3
A and B
A= $or_chart->order_by_x_axis == 1B= $or_chart->order_by_y_axis == 2
ABresult
0X0
100
111
585 0 for my $ar_key ( sort { $h_sort_function{'x_first_array'}->( $a, $b ) } map {[split /\|-\|/, $_]} keys %{$h_axis{y}} ) {
586 0 $h_axis{y}{join '|-|', @{$ar_key}} = $i_counter++;
587 }
588 }
589 else {
590 0 for my $s_key ( sort { $h_sort_function{$h_axis_type{y}}->( $a, $b ) } keys %{$h_axis{y}} ) {
591 0 $h_axis{y}{$s_key} = $i_counter++;
592 }
593 }
594 }
595 # setze die richtigen Label-Verknüpfungen nach der sortierung
596 0 for my $hr_line ( @a_result ) {
597 0 for my $hr_point ( @{$hr_line->{data}} ) {
598 0 for my $s_axis (qw/ x y /) {
599 0 ▶ if ( $h_label_type{$s_axis} eq 'list' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($h_label_type{$s_axis} eq "list") 0 0 0
600 0 $hr_point->{$s_axis} = $h_axis{$s_axis}{delete $hr_point->{$s_axis.'h'}};
601 }
602 }
603 }
604 }
605 # sortiere die Datenpunkte
606 0 AXIS: for my $s_axis (qw/ x y /) {
607 0 ▶ if ( $or_chart->get_column('order_by_'.$s_axis.'_axis') == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($or_chart->get_column('order_by_' . $s_axis . '_axis') == 1) 0 0 0
608 0 for my $hr_line ( @a_result ) {
609 0 @{$hr_line->{data}} = sort { $h_sort_function{$s_axis.'_first_hash'}->( $a, $b ) } @{$hr_line->{data}};
610 }
611 0 last AXIS;
612 }
613 } # AXIS
614  
615 # set chart markings
616 0 for my $or_marking ( $or_chart->chart_markings ) {
617 0 push @a_markings, {
618 chart_marking_name => $or_marking->chart_marking_name,
619 chart_marking_color => $or_marking->chart_marking_color,
620 chart_marking_x_from => $or_marking->chart_marking_x_from,
621 chart_marking_x_to => $or_marking->chart_marking_x_to,
622 chart_marking_y_from => $or_marking->chart_marking_y_from,
623 chart_marking_y_to => $or_marking->chart_marking_y_to,
624 };
625 0 ▶ if ( $a_markings[-1]{chart_marking_x_from} || $a_markings[-1]{chart_marking_x_to} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a_markings[-1]{"chart_marking_x_from"} or $a_markings[-1]{"chart_marking_x_to"}) 0 0 0
Condition0%0/3
$a_markings[-1]{"chart_marking_x_from"} or $a_markings[-1]{"chart_marking_x_to"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$a_markings[-1]{"chart_marking_x_from"} or $a_markings[-1]{"chart_marking_x_to"}
$a_markings[-1]{"chart_marking_x_from"} $a_markings[-1]{"chart_marking_x_to"}
Truth table0%0/3
A or B
A= $a_markings[-1]{"chart_marking_x_from"}B= $a_markings[-1]{"chart_marking_x_to"}
ABresult
1X1
011
000
626 0 ▶ if ( $or_chart->chart_axis_type_x->chart_axis_type_name eq 'date' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($or_chart->chart_axis_type_x->chart_axis_type_name eq "date") 0 0 0
627 0 ▶ if ( my $dt_format = $or_marking->chart_marking_x_format ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $dt_format = $or_marking->chart_marking_x_format) { } 0 0 0
628 0 require DateTime::Format::Strptime;
629 0 my $or_format_x = DateTime::Format::Strptime->new( pattern => $dt_format );
630 0 ▶ $a_markings[-1]{chart_marking_x_from} &&= $formatter->format_datetime($or_format_x->parse_datetime($a_markings[-1]{chart_marking_x_from}));
Condition0%0/3
$a_markings[-1]{"chart_marking_x_from"} &&= $formatter->format_datetime($or_format_x->parse_datetime($a_markings[-1]{"chart_marking_x_from"}))
!ll&&!rl&&r
000
MC/DC0%0/2
$a_markings[-1]{"chart_marking_x_from"} &&= $formatter->format_datetime($or_format_x->parse_datetime($a_markings[-1]{"chart_marking_x_from"}))
$a_markings[-1]{"chart_marking_x_from"} $formatter->format_datetime($or_format_x->parse_datetime($a_markings[-1]{"chart_marking_x_from"}))
Truth table0%0/3
A &&= B
A= $a_markings[-1]{"chart_marking_x_from"}B= $formatter->format_datetime($or_format_x->parse_datetime($a_markings[-1]{"chart_marking_x_from"}))
ABresult
0X0
100
111
631 0 ▶ $a_markings[-1]{chart_marking_x_to} &&= $formatter->format_datetime($or_format_x->parse_datetime($a_markings[-1]{chart_marking_x_to}));
Condition0%0/3
$a_markings[-1]{"chart_marking_x_to"} &&= $formatter->format_datetime($or_format_x->parse_datetime($a_markings[-1]{"chart_marking_x_to"}))
!ll&&!rl&&r
000
MC/DC0%0/2
$a_markings[-1]{"chart_marking_x_to"} &&= $formatter->format_datetime($or_format_x->parse_datetime($a_markings[-1]{"chart_marking_x_to"}))
$a_markings[-1]{"chart_marking_x_to"} $formatter->format_datetime($or_format_x->parse_datetime($a_markings[-1]{"chart_marking_x_to"}))
Truth table0%0/3
A &&= B
A= $a_markings[-1]{"chart_marking_x_to"}B= $formatter->format_datetime($or_format_x->parse_datetime($a_markings[-1]{"chart_marking_x_to"}))
ABresult
0X0
100
111
632 }
633 else {
634 0 $or_c->response->status( 500 );
635 0 $or_c->body('xaxis type is date but no date format is given for marking "' . $or_marking->chart_marking_name . '"');
636 0 return 1;
637 }
638 }
639 }
640 0 ▶ if ( $a_markings[-1]{chart_marking_y_from} || $a_markings[-1]{chart_marking_y_to} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a_markings[-1]{"chart_marking_y_from"} or $a_markings[-1]{"chart_marking_y_to"}) 0 0 0
Condition0%0/3
$a_markings[-1]{"chart_marking_y_from"} or $a_markings[-1]{"chart_marking_y_to"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$a_markings[-1]{"chart_marking_y_from"} or $a_markings[-1]{"chart_marking_y_to"}
$a_markings[-1]{"chart_marking_y_from"} $a_markings[-1]{"chart_marking_y_to"}
Truth table0%0/3
A or B
A= $a_markings[-1]{"chart_marking_y_from"}B= $a_markings[-1]{"chart_marking_y_to"}
ABresult
1X1
011
000
641 0 ▶ if ( $or_chart->chart_axis_type_y->chart_axis_type_name eq 'date' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($or_chart->chart_axis_type_y->chart_axis_type_name eq "date") 0 0 0
642 0 ▶ if ( my $dt_format = $or_marking->chart_marking_y_format ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $dt_format = $or_marking->chart_marking_y_format) { } 0 0 0
643 0 require DateTime::Format::Strptime;
644 0 my $or_format_y = DateTime::Format::Strptime->new( pattern => $dt_format );
645 0 ▶ $a_markings[-1]{chart_marking_y_from} &&= $formatter->format_datetime($or_format_y->parse_datetime($a_markings[-1]{chart_marking_y_from}));
Condition0%0/3
$a_markings[-1]{"chart_marking_y_from"} &&= $formatter->format_datetime($or_format_y->parse_datetime($a_markings[-1]{"chart_marking_y_from"}))
!ll&&!rl&&r
000
MC/DC0%0/2
$a_markings[-1]{"chart_marking_y_from"} &&= $formatter->format_datetime($or_format_y->parse_datetime($a_markings[-1]{"chart_marking_y_from"}))
$a_markings[-1]{"chart_marking_y_from"} $formatter->format_datetime($or_format_y->parse_datetime($a_markings[-1]{"chart_marking_y_from"}))
Truth table0%0/3
A &&= B
A= $a_markings[-1]{"chart_marking_y_from"}B= $formatter->format_datetime($or_format_y->parse_datetime($a_markings[-1]{"chart_marking_y_from"}))
ABresult
0X0
100
111
646 0 ▶ $a_markings[-1]{chart_marking_y_to} &&= $formatter->format_datetime($or_format_y->parse_datetime($a_markings[-1]{chart_marking_y_to}));
Condition0%0/3
$a_markings[-1]{"chart_marking_y_to"} &&= $formatter->format_datetime($or_format_y->parse_datetime($a_markings[-1]{"chart_marking_y_to"}))
!ll&&!rl&&r
000
MC/DC0%0/2
$a_markings[-1]{"chart_marking_y_to"} &&= $formatter->format_datetime($or_format_y->parse_datetime($a_markings[-1]{"chart_marking_y_to"}))
$a_markings[-1]{"chart_marking_y_to"} $formatter->format_datetime($or_format_y->parse_datetime($a_markings[-1]{"chart_marking_y_to"}))
Truth table0%0/3
A &&= B
A= $a_markings[-1]{"chart_marking_y_to"}B= $formatter->format_datetime($or_format_y->parse_datetime($a_markings[-1]{"chart_marking_y_to"}))
ABresult
0X0
100
111
647 }
648 else {
649 0 $or_c->response->status( 500 );
650 0 $or_c->body('yaxis type is date but no date format is given for marking "' . $or_marking->chart_marking_name . '"');
651 0 return 1;
652 }
653 }
654 }
655 }
656  
657 }
658  
659 $or_c->stash->{content} = {
660 chart_type => $or_chart->chart_type->chart_type_flot_name,
661 0 xaxis_alphas => [ map { [ $h_axis{x}{$_}, $_ ] } keys %{$h_axis{x}} ],
662 0 ▶ yaxis_alphas => [ map { [ $h_axis{y}{$_}, $_ ] } keys %{$h_axis{y}} ],
Condition0%0/4
$h_params{'offset'} || 0
l!l
00
$h_params{'limit'} || 0
l!l
00
MC/DC0%0/1
$h_params{'offset'} || 0
$h_params{'offset'}
MC/DC0%0/1
$h_params{'limit'} || 0
$h_params{'limit'}
Truth table0%0/2
A
A= $h_params{'offset'}
Aresult
11
00
Truth table0%0/2
A
A= $h_params{'limit'}
Aresult
11
00
663 xaxis_type => $or_chart->chart_axis_type_x->chart_axis_type_name,
664 yaxis_type => $or_chart->chart_axis_type_y->chart_axis_type_name,
665 order_by_x_axis => $or_chart->order_by_x_axis,
666 order_by_y_axis => $or_chart->order_by_y_axis,
667 0 offset => ($h_params{offset} || 0) + ($h_params{limit} || 0),
668 warnings => \@a_chart_line_point_warnings,
669 markings => \@a_markings,
670 series => \@a_result,
671 };
672  
673 0 return 1;
674  
675 13 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
676  
677 0 ▶sub create_static_url : Local {
Subroutine create_static_url: not called CC=1 SCAR=6.9
Pod undocumented
678  
679 0 my ( $or_self, $or_c ) = @_;
680  
681 0 my $i_chart_tiny_url_id;
682 0 my $or_schema = $or_c->model('TestrunDB');
683 0 my $hr_params = $or_c->req->params;
684  
685 0 ▶ try {
Subroutine __ANON__: not called CC=1 SCAR=6.9
686 0 ▶ $or_schema->txn_do(sub {
Subroutine __ANON__: not called CC=7 SCAR=40.3
687  
688 0 ▶ if ( $hr_params->{ids} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hr_params->{"ids"}) 0 0 0
689  
690 0 require JSON::XS;
691 0 my $ar_ids = JSON::XS::decode_json( $hr_params->{ids} );
692  
693 0 require DateTime;
694 0 my $or_chart_tiny_url = $or_schema->resultset('ChartTinyUrls')->new({
695 created_at => DateTime->now(),
696 });
697 0 $or_chart_tiny_url->insert();
698  
699 0 ▶ if ( $i_chart_tiny_url_id = $or_chart_tiny_url->chart_tiny_url_id ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i_chart_tiny_url_id = $or_chart_tiny_url->chart_tiny_url_id) { } 0 0 0
700 0 for my $hr_chart_line ( @{$ar_ids} ) {
701 0 ▶ if ( $hr_chart_line->{chart_line_id} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hr_chart_line->{'chart_line_id'}) { } 0 0 0
702  
703 my $or_chart_tiny_url_line = $or_schema->resultset('ChartTinyUrlLines')->new({
704 chart_tiny_url_id => $i_chart_tiny_url_id,
705 chart_line_id => $hr_chart_line->{chart_line_id},
706 0 });
707 0 $or_chart_tiny_url_line->insert();
708  
709 0 ▶ if ( my $i_chart_tiny_url_line_id = $or_chart_tiny_url_line->chart_tiny_url_line_id ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $i_chart_tiny_url_line_id = $or_chart_tiny_url_line->chart_tiny_url_line_id) { } 0 0 0
710  
711 0 my @a_relations;
712 0 for my $i_bench_value_id ( @{$hr_chart_line->{data}} ) {
713 0 push @a_relations, {
714 chart_tiny_url_line_id => $or_chart_tiny_url_line->chart_tiny_url_line_id,
715 bench_value_id => $i_bench_value_id,
716 };
717 }
718  
719 0 $or_schema->resultset('ChartTinyUrlRelations')->populate(
720 \@a_relations
721 );
722  
723 }
724 else {
725 0 die "error: cannot insert tiny url line";
726 }
727  
728 }
729 else {
730 0 die "error: cannot find chart line id";
731 }
732 }
733 }
734 else {
735 0 die "error: cannot insert tiny url";
736 }
737 }
738  
739 $or_c->stash->{content} = {
740 0 chart_tiny_url_id => $i_chart_tiny_url_id,
741 };
742  
743 0 });
744 }
745 0 ▶ catch {
Subroutine __ANON__: not called CC=1 SCAR=6.9
746 0 $or_c->res->status( 500 );
747 0 $or_c->response->body( "Transaction failed: $_" );
748 0 };
749  
750 0 return 1;
751  
752 13 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
753  
754 0 ▶sub get_columns : Private {
Subroutine get_columns: not called CC=1 SCAR=6.9
Pod undocumented
755  
756 0 my ( $or_self, $or_c ) = @_;
757  
758 0 require Tapper::Config;
759 0 require BenchmarkAnything::Storage::Frontend::Lib;
760  
761 my $balib = BenchmarkAnything::Storage::Frontend::Lib->new
762 0 (cfgfile => Tapper::Config->subconfig->{_last_used_tapper_config_file});
763  
764 0 my @a_columnlist = @{$balib->listkeys};
765 0 push @a_columnlist, keys %{$balib->_default_additional_keys}; # TODO: too much unrequested data from this?
766  
767 0 return \@a_columnlist;
768  
769 13 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
770  
771 0 ▶sub is_column : Private {
Subroutine is_column: not called CC=3 SCAR=24.8
Pod undocumented
772  
773 0 my ( $or_self, $or_c, $s_column ) = @_;
774  
775 0 require Tapper::Config;
776 0 require BenchmarkAnything::Storage::Frontend::Lib;
777  
778 my $balib = BenchmarkAnything::Storage::Frontend::Lib->new
779 0 (cfgfile => Tapper::Config->subconfig->{_last_used_tapper_config_file});
780  
781 0 my $hr_columns = $balib->_default_additional_keys;
782  
783 0 ▶ return 1 if $hr_columns->{$s_column};
Branch: 1 branch
BranchTrueFalseTotal
if $hr_columns->{$s_column} 0 0 0
784  
785 0 my @a_columnlist = $balib->_get_additional_key_id($s_column);
786  
787 0 ▶ return @a_columnlist ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
@a_columnlist ? : 0 0 0
788  
789 13 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
790  
791 0 ▶sub edit_chart : Local {
Subroutine edit_chart: not called CC=4 SCAR=30.0
Pod undocumented
792  
793 0 my ( $or_self, $or_c ) = @_;
794  
795 # set css file
796 0 push @{$or_c->stash->{css_files}},
797 '/tapper/static/css/metareports/edit.css'
798 , '/tapper/static/css/jquery-ui/jquery.ui.css'
799 ;
800  
801 # set js file
802 0 push @{$or_c->stash->{js_files}}, '/tapper/static/js/jquery-ui/jquery-ui-autocomplete.js';
803  
804 0 my $or_schema = $or_c->model('TestrunDB');
805 0 ▶ if (! $or_c->stash->{chart} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($or_c->stash->{"chart"}) 0 0 0
806 0 ▶ if ( $or_c->req->params->{chart_id} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($or_c->req->params->{'chart_id'}) { } 0 0 0
807 0 $or_c->stash->{chart} = get_edit_page_chart_hash_by_chart_id(
808 $or_c->req->params,
809 $or_schema,
810 );
811 }
812 else {
813 0 $or_c->stash->{chart} = {};
814 }
815 }
816  
817 0 $or_c->stash->{columns} = $or_self->get_columns( $or_c );
818 0 ▶ $or_c->stash->{head_overview} = 'Metareports - Edit' . ( $or_c->req->params->{asnew} ? ' as New' : q## );
Branch: 1 branch
BranchTrueFalseTotal
$or_c->req->params->{'asnew'} ? : 0 0 0
819  
820 0 return 1;
821  
822 13 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
823  
824 0 ▶sub get_edit_page_chart_hash_by_chart_id {
Subroutine get_edit_page_chart_hash_by_chart_id: not called CC=6 SCAR=37.4
Pod undocumented
825  
826 0 my ( $hr_params, $or_schema ) = @_;
827  
828 0 my ( $hr_search, $ar_join ) = hr_get_search( $or_schema, $hr_params );
829 0 my $or_chart = $or_schema->resultset('ChartVersions')->search(
830 $hr_search,
831 {
832 join => $ar_join,
833 prefetch => {
834 'chart' => {
835 'chart_tag_relations' => 'chart_tag',
836 },
837 'chart_lines' => 'chart_additionals',
838 'chart_lines' => {
839 'chart_axis_elements' => [
840 'axis_column',
841 'axis_separator',
842 ],
843 },
844 },
845 },
846 )->first();
847  
848 my $hr_chart = {
849 chart_id => $or_chart->chart_id,
850 chart_version => $or_chart->chart_version,
851 chart_version_id => $or_chart->chart_version_id,
852 chart_name => $or_chart->chart_name,
853 chart_type_id => $or_chart->chart_type_id,
854 chart_axis_type_x_id => $or_chart->chart_axis_type_x_id,
855 chart_axis_type_y_id => $or_chart->chart_axis_type_y_id,
856 order_by_x_axis => $or_chart->order_by_x_axis,
857 order_by_y_axis => $or_chart->order_by_y_axis,
858 chart_lines => [],
859 chart_tag_new => [
860 map {
861 0 $_->chart_tag->chart_tag
862 } $or_chart->chart->chart_tag_relations
863 ],
864 chart_markings => [
865 0 map {{
866 0 chart_marking_name => $_->chart_marking_name,
867 chart_marking_color => $_->chart_marking_color,
868 chart_marking_x_format => $_->chart_marking_x_format,
869 chart_marking_x_from => $_->chart_marking_x_from,
870 chart_marking_x_to => $_->chart_marking_x_to,
871 chart_marking_y_format => $_->chart_marking_y_format,
872 chart_marking_y_from => $_->chart_marking_y_from,
873 chart_marking_y_to => $_->chart_marking_y_to,
874 }} $or_chart->chart_markings
875 ],
876 };
877  
878 0 for my $or_line ( $or_chart->chart_lines ) {
879 0 my ( %h_chart_elements );
880 0 for my $or_element (
881 sort {
882 0 $a->chart_line_axis_element_number <=> $b->chart_line_axis_element_number
883 } $or_line->chart_axis_elements
884 ) {
885 0 ▶ push @{$h_chart_elements{$or_element->chart_line_axis} ||= []},
Branch: 1 branch
BranchTrueFalseTotal
$or_element->axis_column ? : 0 0 0
Condition0%0/2
$h_chart_elements{$or_element->chart_line_axis} ||= []
l!l
00
MC/DC0%0/1
$h_chart_elements{$or_element->chart_line_axis} ||= []
$h_chart_elements{$or_element->chart_line_axis}
Truth table0%0/2
A
A= $h_chart_elements{$or_element->chart_line_axis}
Aresult
11
00
886 $or_element->axis_column
887 ? [ 'column' , $or_element->axis_column->chart_line_axis_column , ]
888 : [ 'separator', $or_element->axis_separator->chart_line_axis_separator, ]
889 ;
890 }
891 0 push @{$hr_chart->{chart_lines}}, {
892 chart_line_name => $or_line->chart_line_name,
893 chart_line_restrictions => [map {{
894 is_template_restriction => $_->is_template_restriction,
895 is_numeric_restriction => $_->is_numeric_restriction,
896 chart_line_restriction_column => $_->chart_line_restriction_column,
897 chart_line_restriction_operator => $_->chart_line_restriction_operator,
898 chart_line_restriction_values => [map {
899 0 $_->chart_line_restriction_value
900 } $_->chart_line_restriction_values],
901 }} $or_line->chart_line_restrictions],
902 chart_line_x_column => $h_chart_elements{x},
903 chart_line_x_format => $or_line->chart_axis_x_column_format(),
904 chart_line_y_column => $h_chart_elements{y},
905 0 chart_line_y_format => $or_line->chart_axis_y_column_format(),
906 chart_additionals => [],
907 };
908 0 for my $or_add ( $or_line->chart_additionals ) {
909 0 push @{$hr_chart->{chart_lines}[-1]{chart_additionals}}, {
910 chart_line_additional_column => $or_add->chart_line_additional_column,
911 chart_line_additional_url => $or_add->chart_line_additional_url,
912 };
913 }
914 }
915  
916 0 return $hr_chart;
917  
918 }
919  
920 0 ▶sub get_undef_on_empty_string {
Subroutine get_undef_on_empty_string: not called CC=3 SCAR=24.8
Pod undocumented
921 0 ▶ return defined $_[0] && $_[0] eq q## ? undef : $_[0];
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] && $_[0] eq '' ? : 0 0 0
Condition0%0/3
defined $_[0] and $_[0] eq ""
!ll&&!rl&&r
000
MC/DC0%0/2
defined $_[0] and $_[0] eq ""
defined $_[0] $_[0] eq ""
Truth table0%0/3
A and B
A= defined $_[0]B= $_[0] eq ""
ABresult
0X0
100
111
922 }
923  
924 0 ▶sub get_edit_page_chart_hash_by_params : Private {
Subroutine get_edit_page_chart_hash_by_params: not called CC=10 SCAR=47.0
Pod undocumented
925  
926 0 my ( $or_self, $or_c, $hr_params, $or_schema ) = @_;
927  
928 0 my @a_chart_marking_name = @{toarrayref($hr_params->{chart_marking_name})};
929 0 my @a_chart_marking_color = @{toarrayref($hr_params->{chart_marking_color})};
930 0 my @a_chart_marking_x_from = @{toarrayref($hr_params->{chart_marking_x_from})};
931 0 my @a_chart_marking_x_to = @{toarrayref($hr_params->{chart_marking_x_to})};
932 0 my @a_chart_marking_x_format = @{toarrayref($hr_params->{chart_marking_x_format})};
933 0 my @a_chart_marking_y_from = @{toarrayref($hr_params->{chart_marking_y_from})};
934 0 my @a_chart_marking_y_to = @{toarrayref($hr_params->{chart_marking_y_to})};
935 0 my @a_chart_marking_y_format = @{toarrayref($hr_params->{chart_marking_y_format})};
936  
937 my $hr_chart = {
938 chart_id => $hr_params->{chart_id},
939 chart_version => $hr_params->{chart_version},
940 chart_version_id => $hr_params->{chart_version_id},
941 chart_name => $hr_params->{chart_name},
942 chart_type_id => $hr_params->{chart_type},
943 chart_axis_type_x_id => $hr_params->{chart_axis_type_x},
944 chart_axis_type_y_id => $hr_params->{chart_axis_type_y},
945 order_by_x_axis => $hr_params->{order_by_x_axis},
946 order_by_y_axis => $hr_params->{order_by_y_axis},
947 chart_lines => [],
948 chart_tag_new => [
949 0 grep { $_ } @{toarrayref($hr_params->{chart_tag_new})}
950 ],
951 0 chart_markings => [map{{
952 0 chart_marking_name => $_,
953 chart_marking_color => shift @a_chart_marking_color,
954 chart_marking_x_from => get_undef_on_empty_string( shift @a_chart_marking_x_from ),
955 chart_marking_x_to => get_undef_on_empty_string( shift @a_chart_marking_x_to ),
956 chart_marking_x_format => get_undef_on_empty_string( shift @a_chart_marking_x_format ),
957 chart_marking_y_from => get_undef_on_empty_string( shift @a_chart_marking_y_from ),
958 chart_marking_y_to => get_undef_on_empty_string( shift @a_chart_marking_y_to),
959 chart_marking_y_format => get_undef_on_empty_string( shift @a_chart_marking_y_format ),
960 }} @a_chart_marking_name],
961 };
962  
963 # column values for chart lines
964 0 my @a_chart_line_names = @{toarrayref($hr_params->{chart_line_name})};
965 0 my @a_chart_line_x_columns = @{toarrayref($hr_params->{chart_axis_x_column})};
966 0 my @a_chart_line_y_columns = @{toarrayref($hr_params->{chart_axis_y_column})};
967 0 my @a_chart_line_x_counters = @{toarrayref($hr_params->{chart_axis_x_counter})};
968 0 my @a_chart_line_y_counters = @{toarrayref($hr_params->{chart_axis_y_counter})};
969 0 my @a_chart_line_x_formats = @{toarrayref($hr_params->{chart_axis_x_format})};
970 0 my @a_chart_line_y_formats = @{toarrayref($hr_params->{chart_axis_y_format})};
971  
972 # column values chart line statements
973 0 my @a_chart_where_counter = @{toarrayref($hr_params->{chart_where_counter})};
974 0 my @a_chart_where_column = @{toarrayref($hr_params->{chart_line_where_column})};
975 0 my @a_chart_where_operator = @{toarrayref($hr_params->{chart_line_where_operator})};
976 0 my @a_chart_value_counter = @{toarrayref($hr_params->{chart_line_where_counter})};
977 0 my @a_chart_where_value = @{toarrayref($hr_params->{chart_line_where_value})};
978 0 my @a_chart_line_where_template = @{toarrayref($hr_params->{chart_line_where_template})};
979 0 my @a_chart_line_where_numeric = @{toarrayref($hr_params->{chart_line_where_numeric})};
980  
981 # additional column data
982 0 my @a_chart_add_counter = @{toarrayref($hr_params->{chart_additional_counter})};
983 0 my @a_chart_add_columns = @{toarrayref($hr_params->{chart_additional_column})};
984 0 my @a_chart_add_urls = @{toarrayref($hr_params->{chart_additional_url})};
985  
986 # get default columns for check
987 0 ▶ while ( my $s_chart_line_name = shift @a_chart_line_names ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $s_chart_line_name = shift @a_chart_line_names) 0 0 0
988  
989 0 my $s_chart_line_x_format = shift @a_chart_line_x_formats;
990 0 my $s_chart_line_y_format = shift @a_chart_line_y_formats;
991 0 my $i_chart_where_counter = shift @a_chart_where_counter;
992 0 my $i_chart_add_counter = shift @a_chart_add_counter;
993 0 my $i_chart_line_x_counter = shift @a_chart_line_x_counters;
994 0 my $i_chart_line_y_counter = shift @a_chart_line_y_counters;
995  
996 0 my @a_act_chart_line_x_columns;
997 0 for my $i_chart_line_x_counter ( 1..$i_chart_line_x_counter ) {
998 0 my $s_chart_line_x_column = shift @a_chart_line_x_columns;
999 0 ▶ if ( $or_self->is_column( $or_c, $s_chart_line_x_column ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($or_self->is_column($or_c, $s_chart_line_x_column)) { } 0 0 0
1000 0 push @a_act_chart_line_x_columns, [ 'column', $s_chart_line_x_column ];
1001 }
1002 else {
1003 0 push @a_act_chart_line_x_columns, [ 'separator', $s_chart_line_x_column ];
1004 }
1005 }
1006  
1007 0 my @a_act_chart_line_y_columns;
1008 0 for my $i_chart_line_y_counter ( 1..$i_chart_line_y_counter ) {
1009 0 my $s_chart_line_y_column = shift @a_chart_line_y_columns;
1010 0 ▶ if ( $or_self->is_column( $or_c, $s_chart_line_y_column ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($or_self->is_column($or_c, $s_chart_line_y_column)) { } 0 0 0
1011 0 push @a_act_chart_line_y_columns, [ 'column', $s_chart_line_y_column ];
1012 }
1013 else {
1014 0 push @a_act_chart_line_y_columns, [ 'separator', $s_chart_line_y_column ];
1015 }
1016 }
1017  
1018 0 my @a_chart_line_restriction;
1019 0 for my $i_where_counter ( 1..$i_chart_where_counter ) {
1020 0 my $i_chart_value_counter = shift @a_chart_value_counter;
1021 push @a_chart_line_restriction, {
1022 is_template_restriction => shift @a_chart_line_where_template,
1023 is_numeric_restriction => shift @a_chart_line_where_numeric,
1024 chart_line_restriction_operator => shift @a_chart_where_operator,
1025 chart_line_restriction_column => shift @a_chart_where_column,
1026 0 chart_line_restriction_values => [map { shift @a_chart_where_value } 1..$i_chart_value_counter],
1027 };
1028 }
1029  
1030 0 ▶ push @{$hr_chart->{chart_lines}}, {
Condition0%0/4
$s_chart_line_x_format || undef
l!l
00
$s_chart_line_y_format || undef
l!l
00
MC/DC0%0/1
$s_chart_line_x_format || undef
$s_chart_line_x_format
MC/DC0%0/1
$s_chart_line_y_format || undef
$s_chart_line_y_format
Truth table0%0/2
A
A= $s_chart_line_x_format
Aresult
11
00
Truth table0%0/2
A
A= $s_chart_line_y_format
Aresult
11
00
1031 chart_line_name => $s_chart_line_name,
1032 chart_line_x_column => \@a_act_chart_line_x_columns,
1033 chart_line_x_format => $s_chart_line_x_format || undef,
1034 chart_line_y_column => \@a_act_chart_line_y_columns,
1035 chart_line_y_format => $s_chart_line_y_format || undef,
1036 chart_line_restrictions => \@a_chart_line_restriction,
1037 chart_additionals => [],
1038 };
1039  
1040 0 for my $i_add_counter ( 1..$i_chart_add_counter ) {
1041 0 push @{$hr_chart->{chart_lines}[-1]{chart_additionals}}, {
1042 chart_line_additional_column => shift @a_chart_add_columns,
1043 chart_line_additional_url => shift @a_chart_add_urls,
1044 };
1045 }
1046  
1047 }
1048  
1049 0 return $hr_chart;
1050  
1051 13 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
1052  
1053 0 ▶sub save_chart : Local {
Subroutine save_chart: not called CC=4 SCAR=30.0
Pod undocumented
1054  
1055 0 my ( $or_self, $or_c ) = @_;
1056  
1057 0 my $or_schema = $or_c->model('TestrunDB');
1058 0 my $hr_params = $or_c->req->params;
1059 my $hr_search_param = {
1060 'chart.active' => 1,
1061 'chart_name' => $hr_params->{chart_name},
1062 0 'chart_version' => \'>= (
1063 SELECT MAX(cv.chart_version)
1064 FROM chart_versions cv
1065 WHERE cv.chart_id = me.chart_id
1066 )',
1067 };
1068  
1069 0 ▶ if ( $hr_params->{chart_id} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hr_params->{"chart_id"}) 0 0 0
1070 0 ▶ if (! $hr_params->{asnew} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($hr_params->{"asnew"}) 0 0 0
1071 0 $hr_search_param->{-not} = { 'me.chart_id' => $hr_params->{chart_id} };
1072 }
1073 }
1074  
1075 # serialize input data
1076 0 $or_c->stash->{chart} = $or_self->get_edit_page_chart_hash_by_params(
1077 $or_c, $hr_params, $or_schema,
1078 );
1079  
1080 0 my @a_charts = $or_schema->resultset('ChartVersions')->search( $hr_search_param, { join => 'chart' } );
1081 0 ▶ if ( @a_charts ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@a_charts) 0 0 0
1082 0 $or_c->stash->{error} = 'chart name already exists';
1083 0 $or_c->go('/tapper/metareports/edit_chart');
1084 }
1085  
1086 0 my $i_chart_id;
1087 0 ▶ try {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1088 0 ▶ $or_schema->txn_do(sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1089 0 ▶ if ( $hr_params->{chart_version_id} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hr_params->{"chart_version_id"}) 0 0 0
1090 $or_c->stash->{error} = $or_self->remove_chart_version(
1091 0 $hr_params->{chart_version_id}, $or_schema
1092 );
1093 }
1094 0 $or_self->insert_chart( $or_c, $or_schema );
1095 0 $or_self->insert_chart_tags( $or_c, $or_schema );
1096 0 $or_self->insert_chart_markings( $or_c, $or_schema, );
1097 0 });
1098 }
1099 0 ▶ catch {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1100 0 $or_c->stash->{error} = "Transaction failed: $_";
1101 0 $or_c->go('/tapper/metareports/edit_chart');
1102 0 };
1103  
1104 $or_c->redirect(
1105 '/tapper/metareports/detail?chart_tag='
1106 . $or_c->req->params->{chart_tag}
1107 . '&amp;chart_id='
1108 . $or_c->stash->{chart}{chart_id}
1109 0 );
1110 0 $or_c->detach();
1111  
1112 0 return 1;
1113  
1114 13 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
1115  
1116 0 ▶sub toarrayref : Private {
Subroutine toarrayref: not called CC=3 SCAR=24.8
Pod undocumented
1117  
1118 0 my ( $value ) = @_;
1119  
1120 0 ▶ if ( not defined $value ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $value) { } 0 0 0
elsif (ref $value ne 'ARRAY') { } 0 0 0
1121 0 return [];
1122 }
1123 elsif ( ref( $value ) ne 'ARRAY' ) {
1124 0 return [ $value ];
1125 }
1126  
1127 0 return $value;
1128  
1129 13 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
1130  
1131 0 ▶sub delete_chart : Local {
Subroutine delete_chart: not called CC=2 SCAR=17.9
Pod undocumented
1132  
1133 0 my ( $or_self, $or_c ) = @_;
1134  
1135 0 my $or_schema = $or_c->model('TestrunDB');
1136  
1137 0 ▶ try {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1138 0 ▶ $or_schema->txn_do(sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1139 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (my $s_error = $or_self->remove_chart($or_c->req->params->{"chart_id"}, $or_schema)) 0 0 0
1140 my $s_error = $or_self->remove_chart(
1141 $or_c->req->params->{chart_id}, $or_schema
1142 )
1143 ) {
1144 0 die "Transaction failed: $s_error";
1145 }
1146 0 });
1147 }
1148 0 ▶ catch {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1149 0 $or_c->stash->{error} = "Transaction failed: $_";
1150 0 };
1151  
1152 0 ▶ if (! $or_c->stash->{error} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($or_c->stash->{"error"}) 0 0 0
1153 0 $or_c->stash->{message} = 'Chart successfully deleted';
1154 }
1155  
1156 0 $or_c->redirect('/tapper/metareports/chart_overview?chart_tag=' . $or_c->req->params->{chart_tag});
1157 0 $or_c->detach();
1158  
1159 0 return 1;
1160  
1161 13 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
1162  
1163 0 ▶sub insert_chart : Private {
Subroutine insert_chart: not called CC=16 SCAR=56.1
Pod undocumented
1164  
1165 0 my ( $or_self, $or_c, $or_schema ) = @_;
1166  
1167 0 my $hr_params = $or_c->stash->{chart};
1168 0 my $i_chart_id = $hr_params->{chart_id};
1169  
1170 0 my $NOW = DateTime->now();
1171 0 ▶ if (! $i_chart_id ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($i_chart_id) 0 0 0
1172 0 my $or_chart = $or_schema->resultset('Charts')->new({
1173 active => 1,
1174 created_at => $NOW,
1175 });
1176 0 $or_chart->insert();
1177 0 $i_chart_id = $or_chart->chart_id;
1178 }
1179  
1180 my $or_chart_version = $or_schema->resultset('ChartVersions')->new({
1181 chart_id => $i_chart_id,
1182 chart_type_id => $hr_params->{chart_type_id},
1183 chart_axis_type_x_id => $hr_params->{chart_axis_type_x_id},
1184 chart_axis_type_y_id => $hr_params->{chart_axis_type_y_id},
1185 chart_version => $hr_params->{chart_id}
1186 ? $or_schema
1187 ->resultset('ChartVersions')
1188 ->search({ chart_id => $i_chart_id })
1189 ->get_column('chart_version')
1190 ->max + 1
1191 : 1,
1192 chart_name => $hr_params->{chart_name},
1193 order_by_x_axis => $hr_params->{order_by_x_axis},
1194 order_by_y_axis => $hr_params->{order_by_y_axis},
1195 0 ▶ created_at => $NOW,
Branch: 1 branch
BranchTrueFalseTotal
$hr_params->{'chart_id'} ? : 0 0 0
1196 });
1197 0 $or_chart_version->insert();
1198  
1199 0 ▶ if ( my $i_chart_version_id = $or_chart_version->chart_version_id() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $i_chart_version_id = $or_chart_version->chart_version_id) { } 0 0 0
1200  
1201 0 my $ar_columns = $or_self->get_columns( $or_c );
1202 0 for my $hr_chart_line ( @{$hr_params->{chart_lines}} ) {
1203  
1204 my $or_chart_line = $or_c->model('TestrunDB')->resultset('ChartLines')->new({
1205 chart_version_id => $i_chart_version_id,
1206 chart_line_name => $hr_chart_line->{chart_line_name},
1207 chart_axis_x_column_format => $hr_chart_line->{chart_line_x_format} || undef,
1208 chart_axis_y_column_format => $hr_chart_line->{chart_line_y_format} || undef,
1209 0 ▶ created_at => $NOW,
Condition0%0/4
$hr_chart_line->{'chart_line_x_format'} || undef
l!l
00
$hr_chart_line->{'chart_line_y_format'} || undef
l!l
00
MC/DC0%0/1
$hr_chart_line->{'chart_line_x_format'} || undef
$hr_chart_line->{'chart_line_x_format'}
MC/DC0%0/1
$hr_chart_line->{'chart_line_y_format'} || undef
$hr_chart_line->{'chart_line_y_format'}
Truth table0%0/2
A
A= $hr_chart_line->{'chart_line_x_format'}
Aresult
11
00
Truth table0%0/2
A
A= $hr_chart_line->{'chart_line_y_format'}
Aresult
11
00
1210 });
1211 0 $or_chart_line->insert();
1212  
1213 0 ▶ if ( my $i_chart_line_id = $or_chart_line->chart_line_id ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $i_chart_line_id = $or_chart_line->chart_line_id) { } 0 0 0
1214 0 for my $s_axis (qw/ x y /) {
1215 0 my $i_chart_line_number = 0;
1216 0 for my $ar_element ( @{$hr_chart_line->{'chart_line_' . $s_axis . '_column'}} ) {
1217 0 my $or_chart_element = $or_c->model('TestrunDB')->resultset('ChartLineAxisElements')->new({
1218 chart_line_id => $i_chart_line_id,
1219 chart_line_axis => $s_axis,
1220 chart_line_axis_element_number => ++$i_chart_line_number,
1221 });
1222 0 $or_chart_element->insert();
1223 0 ▶ if ( my $i_element_id = $or_chart_element->chart_line_axis_element_id ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $i_element_id = $or_chart_element->chart_line_axis_element_id) { } 0 0 0
1224 0 ▶ if ( $ar_element->[0] eq 'column' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ar_element->[0] eq 'column') { } 0 0 0
1225 0 $or_c->model('TestrunDB')->resultset('ChartLineAxisColumns')->new({
1226 chart_line_axis_element_id => $i_element_id,
1227 chart_line_axis_column => $ar_element->[1],
1228 })->insert();
1229 }
1230 else {
1231 0 $or_c->model('TestrunDB')->resultset('ChartLineAxisSeparators')->new({
1232 chart_line_axis_element_id => $i_element_id,
1233 chart_line_axis_separator => $ar_element->[1],
1234 })->insert();
1235 }
1236 }
1237 else {
1238 0 die 'cannot insert chart line element';
1239 }
1240 }
1241 }
1242  
1243 0 for my $hr_additionals ( @{$hr_chart_line->{chart_additionals}} ) {
1244 $or_c->model('TestrunDB')->resultset('ChartLineAdditionals')->new({
1245 chart_line_id => $i_chart_line_id,
1246 chart_line_additional_column => $hr_additionals->{chart_line_additional_column},
1247 chart_line_additional_url => $hr_additionals->{chart_line_additional_url} || undef,
1248 0 ▶ created_at => $NOW,
Condition0%0/2
$hr_additionals->{'chart_line_additional_url'} || undef
l!l
00
MC/DC0%0/1
$hr_additionals->{'chart_line_additional_url'} || undef
$hr_additionals->{'chart_line_additional_url'}
Truth table0%0/2
A
A= $hr_additionals->{'chart_line_additional_url'}
Aresult
11
00
1249 })->insert();
1250 }
1251  
1252 0 for my $hr_chart_line_restriction ( @{$hr_chart_line->{chart_line_restrictions}} ) {
1253  
1254 my $or_chart_line_restriction = $or_c->model('TestrunDB')->resultset('ChartLineRestrictions')->new({
1255 chart_line_id => $i_chart_line_id,
1256 chart_line_restriction_column => $hr_chart_line_restriction->{chart_line_restriction_column},
1257 chart_line_restriction_operator => $hr_chart_line_restriction->{chart_line_restriction_operator},
1258 is_template_restriction => $hr_chart_line_restriction->{is_template_restriction},
1259 is_numeric_restriction => $hr_chart_line_restriction->{is_numeric_restriction},
1260 0 created_at => $NOW,
1261 });
1262 0 $or_chart_line_restriction->insert();
1263  
1264 0 for my $s_chart_line_restriction_value ( @{$hr_chart_line_restriction->{chart_line_restriction_values}} ) {
1265 0 $or_c->model('TestrunDB')->resultset('ChartLineRestrictionValues')->new({
1266 chart_line_restriction_id => $or_chart_line_restriction->chart_line_restriction_id(),
1267 chart_line_restriction_value => $s_chart_line_restriction_value,
1268 })->insert();
1269 }
1270  
1271 }
1272  
1273 # set new chart_id and chart_version_id for later use
1274 0 $hr_params->{chart_id} = $i_chart_id;
1275 0 $hr_params->{chart_version_id} = $i_chart_version_id;
1276  
1277 }
1278 else {
1279 0 die 'cannot insert chart line'
1280 }
1281  
1282 }
1283  
1284 }
1285 else {
1286 0 die 'cannot insert chart';
1287 }
1288  
1289 0 return 1;
1290  
1291 13 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
1292  
1293 0 ▶sub insert_chart_markings : Private {
Subroutine insert_chart_markings: not called CC=2 SCAR=17.9
Pod undocumented
1294  
1295 0 my ( $or_self, $or_c, $or_schema ) = @_;
1296  
1297 0 my $hr_params = $or_c->stash->{chart};
1298 0 for my $hr_marking ( @{$hr_params->{chart_markings}} ) {
1299 $or_schema
1300 ->resultset('ChartMarkings')
1301 0 ->new({ chart_version_id => $hr_params->{chart_version_id}, %{$hr_marking} })
1302 ->insert()
1303 ;
1304 }
1305  
1306 0 return 1;
1307  
1308 13 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
1309  
1310 0 ▶sub insert_chart_tags : Private {
Subroutine insert_chart_tags: not called CC=4 SCAR=30.0
Pod undocumented
1311  
1312 0 my ( $or_self, $or_c, $or_schema ) = @_;
1313  
1314 0 my $hr_params = $or_c->stash->{chart};
1315 my @a_chart_tags = $or_schema
1316 ->resultset('ChartTagRelations')
1317 ->search(
1318 { chart_id => $hr_params->{chart_id} },
1319 0 { prefetch => 'chart_tag' },
1320 )
1321 ;
1322  
1323 0 my %h_chart_tags_new = map { $_ => 1 } @{$hr_params->{chart_tag_new}};
1324 0 for my $or_chart_tag ( @a_chart_tags ) {
1325 0 ▶ if ( $h_chart_tags_new{$or_chart_tag->chart_tag->chart_tag} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($h_chart_tags_new{$or_chart_tag->chart_tag->chart_tag}) { } 0 0 0
1326 0 delete $h_chart_tags_new{$or_chart_tag->chart_tag->chart_tag};
1327 }
1328 else {
1329 0 $or_chart_tag->delete();
1330 }
1331 }
1332  
1333 0 my $NOW = DateTime->now();
1334 0 for my $s_chart_tag ( keys %h_chart_tags_new ) {
1335 $or_schema
1336 ->resultset('ChartTagRelations')
1337 ->find_or_create({
1338 chart_id => $hr_params->{chart_id},
1339 0 chart_tag_id => $or_schema
1340 ->resultset('ChartTags')
1341 ->find_or_create(
1342 { chart_tag => $s_chart_tag, created_at => $NOW },
1343 { key => 'ux_chart_tags_01' },
1344 )->chart_tag_id
1345 ,
1346 created_at => $NOW,
1347 })
1348 ;
1349 }
1350  
1351 0 return 1;
1352  
1353 13 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
1354  
1355 0 ▶sub remove_chart : Private {
Subroutine remove_chart: not called CC=2 SCAR=17.9
Pod undocumented
1356  
1357 0 my ( $or_self, $i_chart_id, $or_schema ) = @_;
1358  
1359 0 ▶ if (! $i_chart_id ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($i_chart_id) 0 0 0
1360 0 return 'chart_id is missing';
1361 }
1362  
1363 0 my $or_chart = $or_schema->resultset('Charts')->find(
1364 $i_chart_id,
1365 );
1366  
1367 0 my $NOW = DateTime->now();
1368 0 $or_chart->active(0);
1369 0 $or_chart->updated_at($NOW);
1370 0 $or_chart->update();
1371  
1372 0 return q##;
1373  
1374 13 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
1375  
1376 0 ▶sub remove_chart_version : Private {
Subroutine remove_chart_version: not called CC=2 SCAR=17.9
Pod undocumented
1377  
1378 0 my ( $or_self, $i_chart_version_id, $or_schema ) = @_;
1379  
1380 0 ▶ if (! $i_chart_version_id ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($i_chart_version_id) 0 0 0
1381 0 return 'chart_version_id is missing';
1382 }
1383  
1384 0 my $or_chart = $or_schema->resultset('ChartVersions')->find(
1385 $i_chart_version_id
1386 );
1387  
1388 0 my $NOW = DateTime->now();
1389 0 $or_chart->active(0);
1390 0 $or_chart->updated_at($NOW);
1391 0 $or_chart->update();
1392  
1393 0 return q##;
1394  
1395 13 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
1396  
1397 0 ▶sub get_benchmark_operators : Private {
Subroutine get_benchmark_operators: not called CC=2 SCAR=17.9
Pod undocumented
1398  
1399 0 my ( $or_self, $or_c ) = @_;
1400  
1401 0 require Tapper::Config;
1402 0 require BenchmarkAnything::Storage::Frontend::Lib;
1403  
1404 my $balib = BenchmarkAnything::Storage::Frontend::Lib->new
1405 0 (cfgfile => Tapper::Config->subconfig->{_last_used_tapper_config_file});
1406  
1407 0 ▶ return @{$balib->_get_benchmark_operators || []};
Condition0%0/2
$balib->_get_benchmark_operators || []
l!l
00
MC/DC0%0/1
$balib->_get_benchmark_operators || []
$balib->_get_benchmark_operators
Truth table0%0/2
A
A= $balib->_get_benchmark_operators
Aresult
11
00
1408  
1409 13 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
1410  
1411 0 ▶sub base : Chained PathPrefix CaptureArgs(0) {
Subroutine base: not called CC=1 SCAR=6.9
Pod undocumented
1412 0 my ( $self, $c ) = @_;
1413 0 my $rule = File::Find::Rule->new;
1414 0 $c->stash(rule => $rule);
1415 13 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
1416  
1417 0 ▶sub prepare_navi : Private {
Subroutine prepare_navi: not called CC=1 SCAR=6.9
Pod undocumented
1418 0 my ( $self, $c ) = @_;
1419  
1420 $c->stash->{navi} = [
1421 {
1422 0 title => "Metareports",
1423 href => "/tapper/metareports/",
1424 },
1425 ];
1426  
1427 13 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
1428  
1429 13 1;
1430  
1431 __END__
↑ Summary blib/lib/Tapper/Reports/Web/Util/Report.pm »