- Updates total subscriber count to exclude trashed records

- Updates unit test
This commit is contained in:
Vlad
2016-11-12 19:33:46 -05:00
parent 1405249712
commit b63ef8cca0
2 changed files with 9 additions and 1 deletions

View File

@@ -648,7 +648,9 @@ class Subscriber extends Model {
return self::whereIn('status', array(
self::STATUS_SUBSCRIBED,
self::STATUS_UNCONFIRMED
))->count();
))
->whereNull('deleted_at')
->count();
}
static function bulkTrash($orm) {

View File

@@ -465,6 +465,12 @@ class SubscriberTest extends MailPoetTest {
'status' => Subscriber::STATUS_UNSUBSCRIBED
));
$subscriber_4 = Subscriber::createOrUpdate(array(
'email' => 'subscriber_4@mailpoet.com',
'status' => Subscriber::STATUS_SUBSCRIBED,
'deleted_at' => Carbon::now()->toDateTimeString()
));
// counts only subscribed & unconfirmed users
$total = Subscriber::getTotalSubscribers();
expect($total)->equals(2);