forked from Kitware/CDash
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFilterController.php
More file actions
133 lines (127 loc) · 3.81 KB
/
FilterController.php
File metadata and controls
133 lines (127 loc) · 3.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
namespace App\Http\Controllers;
use Illuminate\Http\JsonResponse;
final class FilterController extends AbstractController
{
public function getFilterDataArray(): JsonResponse
{
$page_id = $_GET['page_id'] ?? '';
$filterdata = get_filterdata_from_request($page_id);
$fields_to_preserve = [
'filters',
'filtercombine',
'limit',
'othercombine',
'showfilters',
'showlimit',
];
foreach ($filterdata as $key => $value) {
if (!in_array($key, $fields_to_preserve)) {
unset($filterdata[$key]);
}
}
$filterdata['availablefilters'] = self::getFiltersForPage($page_id);
$filterdata['showdaterange'] = self::isDatePage($page_id);
return response()->json(cast_data_for_JSON($filterdata));
}
/**
* Similar to createPageSpecificFilters, but it just returns a list of filter
* names which is handled in javascript.
*
* @return array<string>
*/
private static function getFiltersForPage(string $page_id): array
{
return match ($page_id) {
'index.php', 'viewBuildGroup.php' => [
'buildduration',
'builderrors',
'buildwarnings',
'buildname',
'buildstamp',
'buildstarttime',
'buildtype',
'configureduration',
'configureerrors',
'configurewarnings',
'ctestnotetext',
'expected',
'groupname',
'hascoverage',
'hasctestnotes',
'hasdynamicanalysis',
'hasusernotes',
'label',
'revision',
'site',
'buildgenerator',
'subprojects',
'testsduration',
'testsfailed',
'testsnotrun',
'testspassed',
'testtimestatus',
'updateduration',
'updatedfiles',
],
'indexchildren.php' => [
'buildduration',
'builderrors',
'buildwarnings',
'buildstarttime',
'buildtype',
'configureduration',
'configureerrors',
'configurewarnings',
'ctestnotetext',
'groupname',
'hascoverage',
'hasctestnotes',
'hasdynamicanalysis',
'hasusernotes',
'label',
'buildgenerator',
'subprojects',
'testsduration',
'testsfailed',
'testsnotrun',
'testspassed',
'testtimestatus',
'updateduration',
'updatedfiles',
],
'queryTests.php' => [
'buildname',
'buildstarttime',
'details',
'groupname',
'label',
'revision',
'site',
'status',
'testname',
'testoutput',
'time',
],
'testOverview.php' => [
'buildname',
'subproject',
'testname',
],
default => [],
};
}
private static function isDatePage(string $page_id): bool
{
switch ($page_id) {
case 'index.php':
case 'indexchildren.php':
case 'queryTests.php':
case 'testOverview.php':
case 'viewBuildGroup.php':
return true;
default:
return false;
}
}
}