Add 'Bounced' status to subscribers [MAILPOET-684]

Fix SubscriberTest->testItHasGroupFilter() making only one of four assertions due to lack of data.
Fix a small issue with Import. Unexpected values for the status field were converted to 'unconfirmed' rather than 'subscribed' due to non-strict comparison in in_array(). This hindered 'bounced' status import as well.
This commit is contained in:
Alexey Stoletniy
2016-11-28 19:37:47 +03:00
parent 299c922cef
commit 36b935b9ae
14 changed files with 89 additions and 8 deletions

View File

@ -13,6 +13,7 @@ class Subscriber extends Model {
const STATUS_SUBSCRIBED = 'subscribed';
const STATUS_UNSUBSCRIBED = 'unsubscribed';
const STATUS_UNCONFIRMED = 'unconfirmed';
const STATUS_BOUNCED = 'bounced';
const SUBSCRIPTION_LIMIT_COOLDOWN = 60;
@ -335,6 +336,11 @@ class Subscriber extends Model {
'label' => __('Unsubscribed', 'mailpoet'),
'count' => self::filter(self::STATUS_UNSUBSCRIBED)->count()
),
array(
'name' => self::STATUS_BOUNCED,
'label' => __('Bounced', 'mailpoet'),
'count' => self::filter(self::STATUS_BOUNCED)->count()
),
array(
'name' => 'trash',
'label' => __('Trash', 'mailpoet'),
@ -720,6 +726,12 @@ class Subscriber extends Model {
->where('status', self::STATUS_UNCONFIRMED);
}
static function bounced($orm) {
return $orm
->whereNull('deleted_at')
->where('status', self::STATUS_BOUNCED);
}
static function withoutSegments($orm) {
return $orm->select(MP_SUBSCRIBERS_TABLE.'.*')
->leftOuterJoin(