Skip to content

Commit

Permalink
[BUGFIX] Show correct number of links in dashboard
Browse files Browse the repository at this point in the history
Fix SQL query to correctly count newsletter links

Remove l.uid from GROUP BY clause
Use MAX(l.uid) in SELECT for ONLY_FULL_GROUP_BY compatibility
Ensures accurate link count per newsletter while maintaining SQL mode compliance
  • Loading branch information
einpraegsam committed Oct 16, 2024
1 parent dc38047 commit cc0ab7f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Classes/Domain/Repository/LogRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ public function getNumberOfReceivers(Filter $filter): int
public function getGroupedLinksByHref(Filter $filter): array
{
$connection = DatabaseUtility::getConnectionForTable(Log::TABLE_NAME);
$sql = 'select count(*) as count, l.properties, l.newsletter, l.uid'
$sql = 'select count(*) as count, l.properties, l.newsletter, MAX(l.uid) uid'
. ' from ' . Log::TABLE_NAME . ' l'
. ' left join ' . Newsletter::TABLE_NAME . ' nl on nl.uid=l.newsletter'
. ' left join ' . Configuration::TABLE_NAME . ' c on nl.configuration=c.uid'
. ' where l.deleted=0 and l.status=' . Log::STATUS_LINKOPENING
. ' and c.site in ("' . implode('","', $filter->getSitesForFilter()) . '")'
. ' and nl.crdate>' . $filter->getTimeDateStart()->getTimestamp()
. ' group by l.properties, l.newsletter, l.uid'
. ' group by l.properties, l.newsletter'
. ' order by count desc'
. ' limit ' . $filter->getLimit();
$results = $connection->executeQuery($sql)->fetchAllAssociative();
Expand Down

0 comments on commit cc0ab7f

Please sign in to comment.