Merge pull request #792 from mailpoet/remove_all_lists_fix

Fix 'Subscribers without a list' filter not showing unsubscribed subscribers [MAILPOET-789]
This commit is contained in:
mrcasual
2017-01-19 20:47:58 -05:00
committed by GitHub
2 changed files with 61 additions and 4 deletions

View File

@@ -280,7 +280,9 @@ class Subscriber extends Model {
'value' => ''
);
$subscribers_without_segment = self::filter('withoutSegments')->count();
$subscribers_without_segment = self::filter('withoutSegments')
->whereNull('deleted_at')
->count();
$subscribers_without_segment_label = sprintf(
__('Subscribers without a list (%s)', 'mailpoet'),
number_format($subscribers_without_segment)
@@ -782,13 +784,18 @@ class Subscriber extends Model {
static function withoutSegments($orm) {
return $orm->select(MP_SUBSCRIBERS_TABLE.'.*')
->leftOuterJoin(
MP_SUBSCRIBER_SEGMENT_TABLE,
->rawJoin(
'LEFT OUTER JOIN (
SELECT `subscriber_id`
FROM '.MP_SUBSCRIBER_SEGMENT_TABLE.'
WHERE `status` = "'.self::STATUS_SUBSCRIBED.'"
)',
array(
MP_SUBSCRIBERS_TABLE.'.id',
'=',
MP_SUBSCRIBER_SEGMENT_TABLE.'.subscriber_id'
)
),
MP_SUBSCRIBER_SEGMENT_TABLE
)
->whereNull(MP_SUBSCRIBER_SEGMENT_TABLE.'.subscriber_id');
}