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

Method importFacts

lib/UserMigration/AnalyticsMigrator.php:410–427  ·  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

408 * @throws Exception
409 */
410 private function importFacts(string $uid, array $rows, array $datasetMap): void {
411 foreach ($rows as $row) {
412 $oldDataset = isset($row['dataset']) ? (int)$row['dataset'] : 0;
413 $newDataset = $datasetMap[$oldDataset] ?? null;
414 if ($newDataset === null) {
415 continue;
416 }
417
418 $this->insertAndReturnId('analytics_facts', [
419 'user_id' => $uid,
420 'dataset' => $newDataset,
421 'dimension1' => $row['dimension1'] ?? null,
422 'dimension2' => $row['dimension2'] ?? null,
423 'value' => isset($row['value']) ? (float)$row['value'] : 0.0,
424 'timestamp' => isset($row['timestamp']) ? (int)$row['timestamp'] : time(),
425 ]);
426 }
427 }
428
429 /**
430 * @param list<array<string,mixed>> $rows

Callers 1

importMethod · 0.95

Calls 1

insertAndReturnIdMethod · 0.95

Tested by

no test coverage detected