* Preview the data (one row for column pickers, up to 20 for datasource previews) * * @param $type * @param $options * @return DataResponse|NotFoundResponse * @throws Exception */
($type, $options, int $limit = 1)
| 278 | * @throws Exception |
| 279 | */ |
| 280 | #[NoAdminRequired] |
| 281 | public function readPreview($type, $options, int $limit = 1) { |
| 282 | $reportMetadata = []; |
| 283 | $array = json_decode($options, true); |
| 284 | foreach ($array as $key => $value) { |
| 285 | $array[$key] = htmlspecialchars($value, ENT_NOQUOTES, 'UTF-8'); |
| 286 | } |
| 287 | $reportMetadata['link'] = json_encode($array); |
| 288 | $reportMetadata['type'] = $type; |
| 289 | $reportMetadata['dataset'] = 0; |
| 290 | $reportMetadata['filteroptions'] = ''; |
| 291 | $reportMetadata['user_id'] = $this->userId; |
| 292 | $reportMetadata['id'] = 0; |
| 293 | |
| 294 | $result = $this->getData($reportMetadata); |
| 295 | unset($result['options'], $result['dimensions'], $result['filterApplied'], $result['thresholds']); |
| 296 | $result['data'] = array_slice($result['data'] ?? [], 0, max(1, min($limit, 20))); |
| 297 | |
| 298 | return new DataResponse($result, HTTP::STATUS_OK); |
| 299 | } |
| 300 | |
| 301 | |
| 302 | /** |