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

Method export

lib/UserMigration/AnalyticsMigrator.php:35–59  ·  view source on GitHub ↗
(IUser $user, IExportDestination $exportDestination, OutputInterface $output)

Source from the content-addressed store, hash-verified

33 }
34
35 public function export(IUser $user, IExportDestination $exportDestination, OutputInterface $output): void {
36 $uid = $user->getUID();
37 $output->writeln('<info>Exporting Analytics data</info>');
38
39 $datasets = $this->fetchAllByUser('analytics_dataset', $uid);
40 $datasetIds = array_map(static fn (array $row): int => (int)$row['id'], $datasets);
41
42 $reports = $this->fetchAllByUser('analytics_report', $uid);
43 $reportIds = array_map(static fn (array $row): int => (int)$row['id'], $reports);
44
45 $payload = [
46 'datasets' => $datasets,
47 'reports' => $reports,
48 'dataloads' => $this->fetchAllByIds('analytics_dataload', 'dataset', $datasetIds),
49 'facts' => $this->fetchAllByIds('analytics_facts', 'dataset', $datasetIds),
50 'columns' => $this->fetchAllByIds('analytics_flex_columns', 'dataset_id', $datasetIds),
51 'records' => $this->fetchAllByIds('analytics_flex_records', 'dataset_id', $datasetIds),
52 'values' => $this->fetchAllByIds('analytics_flex_values', 'dataset_id', $datasetIds),
53 'thresholds' => $this->fetchAllByIds('analytics_threshold', 'report', $reportIds),
54 'panoramas' => $this->fetchAllByUser('analytics_panorama', $uid),
55 ];
56
57 $encoded = json_encode($payload, JSON_THROW_ON_ERROR);
58 $exportDestination->addFileContents(self::EXPORT_FILE, $encoded);
59 }
60
61 public function import(IUser $user, IImportSource $importSource, OutputInterface $output): void {
62 if (!$importSource->pathExists(self::EXPORT_FILE)) {

Callers

nothing calls this directly

Calls 4

fetchAllByUserMethod · 0.95
fetchAllByIdsMethod · 0.95
addFileContentsMethod · 0.80
getUIDMethod · 0.45

Tested by

no test coverage detected