Create a temp table for inactive task ids once per run [MAILPOET-2392]

This commit is contained in:
wxa
2019-10-09 12:11:54 +03:00
committed by Jack Kitterhing
parent 622ae8d4df
commit 33c9b51ae6

View File

@ -13,6 +13,8 @@ use MailPoet\Models\Subscriber;
class InactiveSubscribersController { class InactiveSubscribersController {
private $inactives_task_ids_table_created = false;
/** /**
* @param int $days_to_inactive * @param int $days_to_inactive
* @param int $batch_size * @param int $batch_size
@ -71,7 +73,8 @@ class InactiveSubscribersController {
// We take into account only emails which have at least one opening tracked // We take into account only emails which have at least one opening tracked
// to ensure that tracking was enabled for the particular email // to ensure that tracking was enabled for the particular email
$inactives_task_ids_table = sprintf(" if (!$this->inactives_task_ids_table_created) {
$inactives_task_ids_table = sprintf("
CREATE TEMPORARY TABLE IF NOT EXISTS inactives_task_ids CREATE TEMPORARY TABLE IF NOT EXISTS inactives_task_ids
(INDEX task_id_ids (id)) (INDEX task_id_ids (id))
SELECT DISTINCT task_id as id FROM $sending_queues_table as sq SELECT DISTINCT task_id as id FROM $sending_queues_table as sq
@ -87,6 +90,8 @@ class InactiveSubscribersController {
$threshold_date_iso, $day_ago_iso, $threshold_date_iso $threshold_date_iso, $day_ago_iso, $threshold_date_iso
); );
\ORM::rawExecute($inactives_task_ids_table); \ORM::rawExecute($inactives_task_ids_table);
$this->inactives_task_ids_table_created = true;
}
// If MP2 migration occurred during detection interval we can't deactivate subscribers // If MP2 migration occurred during detection interval we can't deactivate subscribers
// because they are imported with original subscription date but they were not present in a list for whole period // because they are imported with original subscription date but they were not present in a list for whole period