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

Method importThresholds

lib/UserMigration/AnalyticsMigrator.php:434–457  ·  view source on GitHub ↗

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

(string $uid, array $rows, array $reportMap, array $reportDatasetMap, array $columnMaps)

Source from the content-addressed store, hash-verified

432 * @throws Exception
433 */
434 private function importThresholds(string $uid, array $rows, array $reportMap, array $reportDatasetMap, array $columnMaps): void {
435 foreach ($rows as $row) {
436 $oldReport = isset($row['report']) ? (int)$row['report'] : 0;
437 $newReport = $reportMap[$oldReport] ?? null;
438 if ($newReport === null) {
439 continue;
440 }
441
442 $this->insertAndReturnId('analytics_threshold', [
443 'user_id' => $uid,
444 'report' => $newReport,
445 'dimension' => $this->normalizeNullableInt($row['dimension'] ?? null),
446 'source_column_ref' => $this->remapReferenceValue(
447 $row['source_column_ref'] ?? null,
448 $columnMaps[$reportDatasetMap[$oldReport] ?? 0] ?? []
449 ),
450 'target' => $row['target'] ?? 0,
451 'option' => $row['option'] ?? '',
452 'severity' => isset($row['severity']) ? (int)$row['severity'] : 0,
453 'coloring' => $row['coloring'] ?? 'row',
454 'sequence' => isset($row['sequence']) ? (int)$row['sequence'] : 1,
455 ]);
456 }
457 }
458
459 /**
460 * Keep nullable integer fields nullable during import instead of coercing them to empty strings.

Callers 1

importMethod · 0.95

Calls 3

insertAndReturnIdMethod · 0.95
normalizeNullableIntMethod · 0.95
remapReferenceValueMethod · 0.95

Tested by

no test coverage detected