1 | <?php |
||
2 | /** |
||
3 | * Analytics |
||
4 | * |
||
5 | * SPDX-FileCopyrightText: 2019-2022 Marcel Scherello |
||
6 | * SPDX-License-Identifier: AGPL-3.0-or-later |
||
7 | */ |
||
8 | |||
9 | namespace OCA\Analytics\Controller; |
||
10 | |||
11 | use OCA\Analytics\Service\DatasetService; |
||
12 | use OCA\Analytics\Service\ReportService; |
||
13 | use OCP\AppFramework\Controller; |
||
0 ignored issues
–
show
|
|||
14 | use OCP\AppFramework\Http\DataResponse; |
||
0 ignored issues
–
show
The type
OCP\AppFramework\Http\DataResponse was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
15 | use OCP\DB\Exception; |
||
0 ignored issues
–
show
The type
OCP\DB\Exception was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
16 | use OCP\IRequest; |
||
0 ignored issues
–
show
The type
OCP\IRequest was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
17 | use Psr\Log\LoggerInterface; |
||
0 ignored issues
–
show
The type
Psr\Log\LoggerInterface was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
18 | |||
19 | class DatasetController extends Controller { |
||
20 | private $logger; |
||
21 | private $DatasetService; |
||
22 | private $ReportService; |
||
23 | |||
24 | public function __construct( |
||
25 | $appName, |
||
26 | IRequest $request, |
||
27 | LoggerInterface $logger, |
||
28 | DatasetService $DatasetService, |
||
29 | ReportService $ReportService, |
||
30 | ) { |
||
31 | parent::__construct($appName, $request); |
||
32 | $this->logger = $logger; |
||
33 | $this->DatasetService = $DatasetService; |
||
34 | $this->ReportService = $ReportService; |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * get all datasets |
||
39 | * |
||
40 | * @NoAdminRequired |
||
41 | * @return DataResponse |
||
42 | */ |
||
43 | public function index() { |
||
44 | return new DataResponse($this->DatasetService->index()); |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * create new dataset |
||
49 | * |
||
50 | * @NoAdminRequired |
||
51 | * @param $name |
||
52 | * @param $dimension1 |
||
53 | * @param $dimension2 |
||
54 | * @param $value |
||
55 | * @return int |
||
56 | * @throws \OCP\DB\Exception |
||
57 | */ |
||
58 | public function create($name, $dimension1, $dimension2, $value) { |
||
59 | return $this->DatasetService->create($name, $dimension1, $dimension2, $value); |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * get own dataset details |
||
64 | * |
||
65 | * @NoAdminRequired |
||
66 | * @param int $datasetId |
||
67 | * @return array|bool |
||
68 | */ |
||
69 | public function read(int $datasetId) { |
||
70 | return $this->DatasetService->readOwn($datasetId); |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * Delete Dataset and all depending objects |
||
75 | * |
||
76 | * @NoAdminRequired |
||
77 | * @param int $datasetId |
||
78 | * @return DataResponse |
||
79 | * @throws \OCP\DB\Exception |
||
80 | */ |
||
81 | public function delete(int $datasetId) { |
||
82 | if ($this->DatasetService->isOwn($datasetId)) { |
||
83 | $reports = $this->ReportService->reportsForDataset($datasetId); |
||
84 | foreach ($reports as $report) { |
||
85 | $this->ReportService->delete((int)$report['id']); |
||
86 | } |
||
87 | $this->DatasetService->delete($datasetId); |
||
88 | return new DataResponse('true'); |
||
89 | } else { |
||
90 | return new DataResponse('false'); |
||
91 | } |
||
92 | } |
||
93 | |||
94 | /** |
||
95 | * get dataset details |
||
96 | * |
||
97 | * @NoAdminRequired |
||
98 | * @param int $datasetId |
||
99 | * @param $name |
||
100 | * @param null $subheader |
||
0 ignored issues
–
show
|
|||
101 | * @param null $dimension1 |
||
0 ignored issues
–
show
|
|||
102 | * @param null $dimension2 |
||
0 ignored issues
–
show
|
|||
103 | * @param null $value |
||
0 ignored issues
–
show
|
|||
104 | * @param null $aiIndex |
||
0 ignored issues
–
show
|
|||
105 | * @return bool |
||
106 | * @throws Exception |
||
107 | */ |
||
108 | public function update( |
||
109 | int $datasetId, |
||
110 | $name, |
||
111 | $subheader = null, |
||
112 | $dimension1 = null, |
||
113 | $dimension2 = null, |
||
114 | $value = null, |
||
115 | $aiIndex = null |
||
116 | ) { |
||
117 | return $this->DatasetService->update($datasetId, $name, $subheader, $dimension1, $dimension2, $value, $aiIndex); |
||
118 | } |
||
119 | |||
120 | /** |
||
121 | * get status of the dataset |
||
122 | * |
||
123 | * @NoAdminRequired |
||
124 | * @param int $datasetId |
||
125 | * @throws \OCP\DB\Exception |
||
126 | */ |
||
127 | public function status(int $datasetId) { |
||
128 | return $this->DatasetService->status($datasetId); |
||
129 | } |
||
130 | |||
131 | /** |
||
132 | * Update the context chat provider |
||
133 | * |
||
134 | * @NoAdminRequired |
||
135 | * @param int $datasetId |
||
136 | * @return DataResponse |
||
137 | */ |
||
138 | public function provider(int $datasetId) { |
||
139 | if ($this->DatasetService->isOwn($datasetId)) { |
||
140 | $this->DatasetService->provider($datasetId); |
||
141 | return new DataResponse('true'); |
||
142 | } else { |
||
143 | return new DataResponse('false'); |
||
144 | } |
||
145 | } |
||
146 | } |
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