MCPcopy Create free account
hub / github.com/Rello/analytics / readPreview

Method readPreview

lib/Controller/OutputController.php:280–299  ·  view source on GitHub ↗

* Preview the data (one row for column pickers, up to 20 for datasource previews) * * @param $type * @param $options * @return DataResponse|NotFoundResponse * @throws Exception */

(int $type, $options, int $limit = 1)

Source from the content-addressed store, hash-verified

278 * @throws Exception
279 */
280 #[NoAdminRequired]
281 public function readPreview(int $type, $options, int $limit = 1) {
282 $reportMetadata = [];
283 try {
284 $reportMetadata['link'] = $this->DatasourceController->encodeOptionsForStorage($type, $options);
285 } catch (\InvalidArgumentException $e) {
286 return new DataResponse(['error' => $e->getMessage()], 400);
287 }
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 /**

Callers

nothing calls this directly

Calls 2

getDataMethod · 0.95

Tested by

no test coverage detected