Consider also confirmed_at for subscribers deactivation
[MAILPOET-1791]
This commit is contained in:
committed by
M. Shull
parent
8e46f12a0e
commit
a8584523d3
@ -74,9 +74,9 @@ class InactiveSubscribersController {
|
||||
JOIN $scheduled_task_subcribres_table as sts ON s.id = sts.subscriber_id
|
||||
JOIN ($scheduled_task_ids_query) task_ids ON task_ids.id = sts.task_id
|
||||
LEFT OUTER JOIN $statistics_opens_table as so ON s.id = so.subscriber_id AND so.created_at > ?
|
||||
WHERE s.created_at < ? AND s.status = ? AND so.id IS NULL
|
||||
WHERE s.created_at < ? AND (s.confirmed_at IS NULL OR s.confirmed_at < ?) AND s.status = ? AND so.id IS NULL
|
||||
GROUP BY s.id LIMIT ?",
|
||||
[$threshold_date_iso, $threshold_date_iso, Subscriber::STATUS_SUBSCRIBED, $batch_size]
|
||||
[$threshold_date_iso, $threshold_date_iso, $threshold_date_iso, Subscriber::STATUS_SUBSCRIBED, $batch_size]
|
||||
)->findArray();
|
||||
|
||||
$ids_to_deactivate = array_map(
|
||||
|
@ -76,7 +76,7 @@ class InactiveSubscribersControllerTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
function testItDoesNotDeactivateNewSubscriberWithUnopenedEmail() {
|
||||
list($task) = $this->createCompletedSendingTaskWithOneOpen(1);
|
||||
list($task) = $this->createCompletedSendingTaskWithOneOpen(3);
|
||||
|
||||
$subscriber = $this->createSubscriber('s1@email.com', 2);
|
||||
$this->addSubcriberToTask($subscriber, $task);
|
||||
@ -87,8 +87,22 @@ class InactiveSubscribersControllerTest extends \MailPoetTest {
|
||||
expect($subscriber->status)->equals(Subscriber::STATUS_SUBSCRIBED);
|
||||
}
|
||||
|
||||
function testItDoesNotDeactivateNewlyConfirmedSubscriberWithUnopenedEmail() {
|
||||
list($task) = $this->createCompletedSendingTaskWithOneOpen(3);
|
||||
|
||||
$subscriber = $this->createSubscriber('s1@email.com', 10);
|
||||
$subscriber->confirmed_at = (new Carbon())->subDays(2)->toDateTimeString();
|
||||
$subscriber->save();
|
||||
$this->addSubcriberToTask($subscriber, $task);
|
||||
|
||||
$result = $this->controller->markInactiveSubscribers(5, 100);
|
||||
expect($result)->equals(0);
|
||||
$subscriber = Subscriber::findOne($subscriber->id);
|
||||
expect($subscriber->status)->equals(Subscriber::STATUS_SUBSCRIBED);
|
||||
}
|
||||
|
||||
function testItDoesNotDeactivateSubscriberWithoutSentEmail() {
|
||||
$this->createCompletedSendingTaskWithOneOpen(1);
|
||||
$this->createCompletedSendingTaskWithOneOpen(3);
|
||||
$subscriber = $this->createSubscriber('s1@email.com', 10);
|
||||
$result = $this->controller->markInactiveSubscribers(5, 100);
|
||||
expect($result)->equals(0);
|
||||
|
Reference in New Issue
Block a user