Use Newsletter Link Entity in Stats Notifications
[MAILPOET-2439]
This commit is contained in:
committed by
Jack Kitterhing
parent
4c960a1a44
commit
ad6e6009d2
@ -12,27 +12,4 @@ namespace MailPoet\Models;
|
||||
class NewsletterLink extends Model {
|
||||
public static $_table = MP_NEWSLETTER_LINKS_TABLE;
|
||||
const UNSUBSCRIBE_LINK_SHORT_CODE = '[link:subscription_unsubscribe_url]';
|
||||
|
||||
/**
|
||||
* @param Newsletter $newsletter
|
||||
* @return NewsletterLink|null
|
||||
*/
|
||||
static function findTopLinkForNewsletter(Newsletter $newsletter) {
|
||||
$link = self::selectExpr('links.*')
|
||||
->selectExpr('count(*)', 'clicksCount')
|
||||
->tableAlias('links')
|
||||
->innerJoin(StatisticsClicks::$_table,
|
||||
['clicks.link_id', '=', 'links.id'],
|
||||
'clicks')
|
||||
->where('newsletter_id', $newsletter->id())
|
||||
->groupBy('links.id')
|
||||
->orderByDesc('clicksCount')
|
||||
->limit(1)
|
||||
->findOne();
|
||||
if (!$link) {
|
||||
return null;
|
||||
}
|
||||
return $link;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user