1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* vim: set expandtab sw=4 ts=4 sts=4: */ |
4
|
|
|
|
5
|
|
|
namespace App\View\Helper; |
6
|
|
|
|
7
|
|
|
use App\Utility\Sanitize; |
|
|
|
|
8
|
|
|
use App\View\Helper\AppHelper; |
9
|
|
|
use Cake\Utility\Inflector; |
10
|
|
|
use Cake\View\View; |
11
|
|
|
|
12
|
|
|
class ReportsHelper extends AppHelper |
13
|
|
|
{ |
14
|
|
|
public $helpers = ['Incidents']; |
15
|
|
|
|
16
|
5 |
|
public function __construct(View $view, $settings = []) |
17
|
|
|
{ |
18
|
5 |
|
parent::__construct($view, $settings); |
19
|
5 |
|
} |
20
|
|
|
|
21
|
1 |
|
public function entriesFromIncidents($entries, $totalCount, $key) |
22
|
|
|
{ |
23
|
|
|
//$entries = Sanitize::clean($entries); |
24
|
1 |
|
$values = []; |
25
|
1 |
|
foreach ($entries as $entry) { |
26
|
1 |
|
$values[] = "$entry[$key] <span class='count'>(" |
27
|
1 |
|
. $entry['count'] . ')</span>'; |
28
|
|
|
} |
29
|
1 |
|
$fullString = implode(', ', $values); |
30
|
1 |
|
$remaining = $totalCount - count($values); |
31
|
1 |
|
if ($remaining) { |
32
|
|
|
$fullString .= " <small>and $remaining others</small>"; |
33
|
|
|
} |
34
|
|
|
|
35
|
1 |
|
return $fullString; |
36
|
|
|
} |
37
|
|
|
|
38
|
1 |
|
public function createReportsLinks($reports) |
39
|
|
|
{ |
40
|
1 |
|
$links = []; |
41
|
1 |
|
foreach ($reports as $report) { |
42
|
1 |
|
$links[] = $this->linkToReport($report); |
43
|
|
|
} |
44
|
1 |
|
$string = implode(', ', $links); |
45
|
|
|
|
46
|
1 |
|
return $string; |
47
|
|
|
} |
48
|
|
|
|
49
|
3 |
|
public function linkToReport($report) |
50
|
|
|
{ |
51
|
3 |
|
$reportId = $report['id']; |
52
|
3 |
|
$link = '<a href=/' . BASE_DIR . "reports/view/$reportId>#$reportId</a>"; |
53
|
|
|
|
54
|
3 |
|
return $link; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function linkToReportFromIncident($incident) |
58
|
|
|
{ |
59
|
|
|
$reportId = $incident['report_id']; |
60
|
|
|
$link = '<a href=/' . BASE_DIR . "reports/view/$reportId>#$reportId</a>"; |
61
|
|
|
|
62
|
|
|
return $link; |
63
|
|
|
} |
64
|
|
|
|
65
|
1 |
|
public function getStacktracesForIncidents($incidents) |
66
|
|
|
{ |
67
|
1 |
|
$count = 0; |
68
|
1 |
|
$html = '<div class="row">'; |
69
|
1 |
|
foreach ($incidents as $incident) { |
70
|
1 |
|
$class = 'well span5'; |
71
|
|
|
|
72
|
1 |
|
if ($count % 2 == 1) { |
73
|
|
|
$class .= ' '; |
74
|
|
|
} else { |
75
|
1 |
|
$html .= "</div><div class='row'>"; |
76
|
|
|
} |
77
|
|
|
|
78
|
1 |
|
$html .= $this->Incidents->getStacktrace($incident, $class); |
|
|
|
|
79
|
1 |
|
++$count; |
80
|
|
|
} |
81
|
1 |
|
$html .= '</div>'; |
82
|
|
|
|
83
|
1 |
|
return $html; |
84
|
|
|
} |
85
|
|
|
|
86
|
1 |
|
public function getChartArray($arrayName, $columns, $relatedEntries) |
87
|
|
|
{ |
88
|
1 |
|
$html = "var $arrayName = [], chart = {};"; |
89
|
1 |
|
foreach ($columns as $column) { |
90
|
1 |
|
$column = htmlspecialchars($column, ENT_QUOTES | ENT_HTML5); |
91
|
1 |
|
$html .= 'chart = {};'; |
92
|
1 |
|
$html .= "chart.name = '$column';"; |
93
|
1 |
|
$html .= "chart.title = '" . Inflector::humanize($column) . "';"; |
94
|
1 |
|
$html .= 'chart.labels = []; chart.values = [];'; |
95
|
1 |
|
foreach ($relatedEntries[$column] as $entry) { |
96
|
1 |
|
$count = $entry['count']; |
97
|
1 |
|
$html .= "chart.labels.push('$entry[$column] ($count)');"; |
98
|
1 |
|
$html .= "chart.values.push($count);"; |
99
|
|
|
} |
100
|
1 |
|
$html .= "$arrayName.push(chart);"; |
101
|
|
|
} |
102
|
|
|
|
103
|
1 |
|
return $html; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
public function getLineChartData($arrayName, $entries) |
107
|
|
|
{ |
108
|
|
|
$html = "var $arrayName = [];"; |
109
|
|
|
foreach ($entries as $entry) { |
110
|
|
|
$html .= "$arrayName.push(['" . $entry['date'] . "', " |
111
|
|
|
. $entry['count'] . ']);'; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
return $html; |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths