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

Method addData

lib/Controller/ApiDataController.php:69–97  ·  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

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