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

Method importFacts

lib/UserMigration/AnalyticsMigrator.php:284–301  ·  view source on GitHub ↗

* @param list > $rows * @param array $datasetMap * @throws Exception */

(string $uid, array $rows, array $datasetMap)

Source from the content-addressed store, hash-verified

282 * @throws Exception
283 */
284 private function importFacts(string $uid, array $rows, array $datasetMap): void {
285 foreach ($rows as $row) {
286 $oldDataset = isset($row['dataset']) ? (int)$row['dataset'] : 0;
287 $newDataset = $datasetMap[$oldDataset] ?? null;
288 if ($newDataset === null) {
289 continue;
290 }
291
292 $this->insertAndReturnId('analytics_facts', [
293 'user_id' => $uid,
294 'dataset' => $newDataset,
295 'dimension1' => $row['dimension1'] ?? null,
296 'dimension2' => $row['dimension2'] ?? null,
297 'value' => isset($row['value']) ? (float)$row['value'] : 0.0,
298 'timestamp' => isset($row['timestamp']) ? (int)$row['timestamp'] : time(),
299 ]);
300 }
301 }
302
303 /**
304 * @param list<array<string,mixed>> $rows

Callers 1

importMethod · 0.95

Calls 1

insertAndReturnIdMethod · 0.95

Tested by

no test coverage detected