public function sumRowMetadata($rowToSum, $aggregationOperations = array())
{
if (!empty($rowToSum->metadata) && !$this->isSummaryRow()) {
$aggregatedMetadata = array();
if (is_array($aggregationOperations)) {
// we need to aggregate value before value is overwritten by maybe another row
foreach ($aggregationOperations as $columnn => $operation) {
$thisMetadata = $this->getMetadata($columnn);
$sumMetadata = $rowToSum->getMetadata($columnn);
if ($thisMetadata === false && $sumMetadata === false) {
continue;
}
$aggregatedMetadata[$columnn] = $this->getColumnValuesMerged($operation, $thisMetadata, $sumMetadata, $this, $rowToSum);
}
}
// We shall update metadata, and keep the metadata with the _most visits or pageviews_, rather than first or last seen
$visits = max($rowToSum->getColumn(Metrics::INDEX_PAGE_NB_HITS) || $rowToSum->getColumn(Metrics::INDEX_NB_VISITS), $rowToSum->getColumn('nb_actions') || $rowToSum->getColumn('nb_visits'));
if ($visits && $visits > $this->maxVisitsSummed || empty($this->metadata)) {
$this->maxVisitsSummed = $visits;
$this->metadata = $rowToSum->metadata;
}
foreach ($aggregatedMetadata as $column => $value) {
// we need to make sure aggregated value is used, and not metadata from $rowToSum
$this->setMetadata($column, $value);
}
}
}