From 6966f0fd64485c09f841badadc0b35b883e4cd04 Mon Sep 17 00:00:00 2001 From: Altamash Shaikh Date: Fri, 10 Jan 2025 20:42:54 +0530 Subject: [PATCH] Changes lower case logic to DB, #PG-4087, #174 --- RecordBuilders/CampaignReporting.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/RecordBuilders/CampaignReporting.php b/RecordBuilders/CampaignReporting.php index f6d8dd4..6142123 100644 --- a/RecordBuilders/CampaignReporting.php +++ b/RecordBuilders/CampaignReporting.php @@ -79,6 +79,16 @@ protected function aggregate(ArchiveProcessor $archiveProcessor): array */ protected function aggregateFromLogs(LogAggregator $logAggregator, array $records, $dimensions, $table, $aggregatorMethod): void { + $systemSettings = StaticContainer::get(SystemSettings::class); + if (!$systemSettings->doNotChangeCaseOfUtmParameters->getValue()) { + $newDimensions = []; + foreach($dimensions as $dimension) { + $lowerDimensionColumn = $table . '.' . $dimension; + $newDimensions[$dimension] = "LOWER($lowerDimensionColumn)"; + } + $dimensions = $newDimensions; + } + $whereClause = $table . ".referer_type = " . Common::REFERRER_TYPE_CAMPAIGN; $query = $aggregatorMethod === 'queryConversionsByDimension' && version_compare(Version::VERSION, '5.2.0-b6', '>=') ? $logAggregator->$aggregatorMethod($dimensions, $whereClause, [], [], false, false, true) @@ -134,7 +144,6 @@ protected function aggregateFromLogs(LogAggregator $logAggregator, array $record protected function getLabelFromRowDimensions(array $dimensionsAsLabel, array $row): string { - $systemSettings = StaticContainer::get(SystemSettings::class); $labels = []; foreach ($dimensionsAsLabel as $dimensionLabelPart) { if ( @@ -144,12 +153,8 @@ protected function getLabelFromRowDimensions(array $dimensionsAsLabel, array $ro $labels[] = $row[$dimensionLabelPart]; } } - $label = implode(Archiver::SEPARATOR_COMBINED_DIMENSIONS, $labels); - if ($label && !$systemSettings->doNotChangeCaseOfUtmParameters->getValue()) { - $label = Common::mb_strtolower($label); - } - return $label; + return implode(Archiver::SEPARATOR_COMBINED_DIMENSIONS, $labels); } protected function getRecordToDimensions(): array