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

Method addData

lib/Controller/ApiDataController.php:65–93  ·  view source on GitHub ↗

* add data via there database names * @param int $datasetId * @return DataResponse * @throws \Exception */

(int $datasetId)

Source from the content-addressed store, hash-verified

63 * @throws \Exception
64 */
65 #[NoAdminRequired]
66 #[NoCSRFRequired]
67 #[CORS]
68 public function addData(int $datasetId) {
69 $datasetId = $this->getDatasetIdFromRoute($datasetId);
70 $params = $this->request->getParams();
71 $datasetMetadata = $this->DatasetService->readOwn($datasetId);
72
73 $response = $this->deriveMaintenancePossible($datasetMetadata);
74 if ($response !== true) return $response;
75
76 if (!isset($params['dimension1'])) {
77 $this->errors[] = 'Dimension 1 required';
78 } elseif (!isset($params['dimension2'])) {
79 $this->errors[] = 'Dimension 2 required';
80 } elseif (!isset($params['dimension3'])) {
81 $this->errors[] = 'Dimension 3 required';
82 }
83 if (!empty($this->errors)) {
84 return $this->requestResponse(false, self::MISSING_PARAM, implode(',', $this->errors));
85 }
86
87 $this->StorageService->update($datasetId, $params['dimension1'], $params['dimension2'], $params['dimension3']);
88
89 // Update the Context Chat backend
90 $this->DatasetService->provider($datasetId);
91
92 return $this->requestResponse(true, Http::STATUS_OK, 'Data update successful');
93 }
94
95 /**
96 * add data via there real field names

Callers

nothing calls this directly

Calls 6

getDatasetIdFromRouteMethod · 0.95
requestResponseMethod · 0.95
readOwnMethod · 0.45
updateMethod · 0.45
providerMethod · 0.45

Tested by

no test coverage detected