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 */

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

Source from the content-addressed store, hash-verified

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 /**

Callers

nothing calls this directly

Calls 1

getDataMethod · 0.95

Tested by

no test coverage detected