From 19e6c7b3041d685585e405b6b4889b8ae8e9c16c Mon Sep 17 00:00:00 2001 From: sgiehl Date: Mon, 13 Jan 2025 11:02:54 +0100 Subject: [PATCH] Ignore aggregated rows for totals --- core/API/DataTableManipulator/ReportTotalsCalculator.php | 4 ++++ plugins/API/ProcessedReport.php | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/core/API/DataTableManipulator/ReportTotalsCalculator.php b/core/API/DataTableManipulator/ReportTotalsCalculator.php index d83f393f09a..c559c8dcbcf 100644 --- a/core/API/DataTableManipulator/ReportTotalsCalculator.php +++ b/core/API/DataTableManipulator/ReportTotalsCalculator.php @@ -107,6 +107,10 @@ protected function manipulateDataTable($dataTable) /** @var DataTable\Row $totalRow */ $totalRow = null; foreach ($firstLevelTable->getRows() as $row) { + if ($row->getMetadata('is_aggregate') == '1') { + continue; // skip aggregated row added by flattening + } + if (!isset($totalRow)) { $columns = $row->getColumns(); $columns['label'] = DataTable::LABEL_TOTALS_ROW; diff --git a/plugins/API/ProcessedReport.php b/plugins/API/ProcessedReport.php index 940e00d74f9..2096601979e 100644 --- a/plugins/API/ProcessedReport.php +++ b/plugins/API/ProcessedReport.php @@ -400,6 +400,7 @@ public function getProcessedReport( 'serialize' => '0', 'language' => $language, 'idSubtable' => $idSubtable, + 'keep_totals_row' => 1, )); if (!empty($segment)) { @@ -778,7 +779,7 @@ private function handleSimpleDataTable($idSite, $simpleDataTable, $metadataColum private function aggregateReportTotalValues($simpleDataTable, $metadateColumns, $totals) { - $metadataTotals = $simpleDataTable->getMetadata('totals'); + $metadataTotals = $simpleDataTable->getTotalsRow(); if (empty($metadataTotals)) { return $totals;