Render newsletters without clicked links

[MAILPOET-1571]
This commit is contained in:
Pavel Dohnal
2019-01-22 13:15:20 +01:00
parent de106e8828
commit 9eeda50b07
3 changed files with 45 additions and 5 deletions

View File

@ -7,7 +7,7 @@ class NewsletterLink extends Model {
public static $_table = MP_NEWSLETTER_LINKS_TABLE;
static function findTopLinkForNewsletter(Newsletter $newsletter) {
return self::selectExpr('links.*')
$link = self::selectExpr('links.*')
->selectExpr('count(*)', 'clicksCount')
->tableAlias('links')
->innerJoin(StatisticsClicks::$_table,
@ -18,6 +18,10 @@ class NewsletterLink extends Model {
->orderByDesc('clicksCount')
->limit(1)
->findOne();
if(!$link) {
return null;
}
return $link;
}
}