Skip to content

Commit

Permalink
Merge pull request #7834 from mautic-inc/staging.multiple-emails-repo…
Browse files Browse the repository at this point in the history
…rt-fix

Report not showing properly clicks for multiple emails
  • Loading branch information
dennisameling committed Mar 19, 2020
2 parents 85f8db3 + 6c630dc commit 16b47b7
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/bundles/EmailBundle/EventListener/ReportSubscriber.php
Expand Up @@ -376,8 +376,8 @@ public function onReportGenerate(ReportGeneratorEvent $event)

if ($event->hasFilter('e.id')) {
$filterParam = $event->createParameterName();
$qbcut->andWhere("cut2.channel_id = :{$filterParam}");
$qb->setParameter($filterParam, $event->getFilterValue('e.id'), \PDO::PARAM_INT);
$qbcut->andWhere($qb->expr()->in('cut2.channel_id', ":{$filterParam}"));
$qb->setParameter($filterParam, $event->getFilterValues('e.id'), Connection::PARAM_INT_ARRAY);
}

$qb->leftJoin(
Expand Down
25 changes: 25 additions & 0 deletions app/bundles/ReportBundle/Entity/Report.php
Expand Up @@ -384,6 +384,31 @@ public function getFilterValue($column)
throw new \UnexpectedValueException("Column {$column} doesn't have any filter.");
}

/**
* Get filter values from a specific filter.
*
* @param string $column
*
* @return array
*
* @throws \UnexpectedValueException
*/
public function getFilterValues($column)
{
$values = [];
foreach ($this->getFilters() as $field) {
if ($column === $field['column']) {
$values[] = $field['value'];
}
}

if (empty($values)) {
throw new \UnexpectedValueException("Column {$column} doesn't have any filter.");
}

return $values;
}

/**
* @return mixed
*/
Expand Down
14 changes: 14 additions & 0 deletions app/bundles/ReportBundle/Event/ReportGeneratorEvent.php
Expand Up @@ -447,6 +447,20 @@ public function getFilterValue($column)
return $this->getReport()->getFilterValue($column);
}

/**
* Get filter values from a specific filter.
*
* @param string $column
*
* @return array
*
* @throws \UnexpectedValueException
*/
public function getFilterValues($column)
{
return $this->getReport()->getFilterValues($column);
}

/**
* Check if the report has a groupBy columns selected.
*
Expand Down
3 changes: 3 additions & 0 deletions app/bundles/ReportBundle/Model/ReportModel.php
Expand Up @@ -692,6 +692,9 @@ public function getReportData(Report $entity, FormFactoryInterface $formFactory
$params = $query->getParameters();

foreach ($params as $name => $param) {
if (is_array($param)) {
$param = implode("','", $param);
}
$debugData['query'] = str_replace(":$name", "'$param'", $debugData['query']);
}

Expand Down

0 comments on commit 16b47b7

Please sign in to comment.