diff --git a/lib/Config/Database.php b/lib/Config/Database.php index 152885ee91..d5c70d1d34 100644 --- a/lib/Config/Database.php +++ b/lib/Config/Database.php @@ -86,6 +86,7 @@ class Database { $statistics_forms = Env::$db_prefix . 'statistics_forms'; $mapping_to_external_entities = Env::$db_prefix . 'mapping_to_external_entities'; $log = Env::$db_prefix . 'log'; + $stats_notifications = Env::$db_prefix . 'stats_notifications'; define('MP_SETTINGS_TABLE', $settings); define('MP_SEGMENTS_TABLE', $segments); @@ -112,6 +113,7 @@ class Database { define('MP_STATISTICS_FORMS_TABLE', $statistics_forms); define('MP_MAPPING_TO_EXTERNAL_ENTITIES_TABLE', $mapping_to_external_entities); define('MP_LOG_TABLE', $log); + define('MP_STATS_NOTIFICATIONS_TABLE', $stats_notifications); } } } diff --git a/lib/Config/Migrator.php b/lib/Config/Migrator.php index 2f195f0ec8..86982d02e7 100644 --- a/lib/Config/Migrator.php +++ b/lib/Config/Migrator.php @@ -18,6 +18,7 @@ class Migrator { 'settings', 'custom_fields', 'scheduled_tasks', + 'stats_notifications', 'scheduled_task_subscribers', 'sending_queues', 'subscribers', @@ -126,6 +127,18 @@ class Migrator { return $this->sqlify(__FUNCTION__, $attributes); } + function statsNotifications() { + $attributes = array( + 'id int(11) unsigned NOT NULL AUTO_INCREMENT,', + 'newsletter_id int(11) unsigned NOT NULL,', + 'task_id int(11) unsigned NOT NULL,', + 'PRIMARY KEY (id),', + 'KEY newsletter_id (newsletter_id),', + 'KEY task_id (task_id)', + ); + return $this->sqlify(__FUNCTION__, $attributes); + } + function scheduledTaskSubscribers() { $attributes = array( 'task_id int(11) unsigned NOT NULL,', diff --git a/lib/Cron/Workers/StatsNotifications.php b/lib/Cron/Workers/StatsNotifications.php index 03bf1aee55..7f6125b0cd 100644 --- a/lib/Cron/Workers/StatsNotifications.php +++ b/lib/Cron/Workers/StatsNotifications.php @@ -6,7 +6,18 @@ use Carbon\Carbon; use MailPoet\Models\SendingQueue; use MailPoet\Models\ScheduledTask; use MailPoet\Models\Setting; -use MailPoet\Tasks\Sending; + + +/** + * TODO: + * - finish stats_notifications table, test if it is working and the migration is creating the table + * - remove all the SendingQueue from here + * - in schedule method add a row to stats_notifications table + * - when sending of post notification or a standard newsletter is finished call schedule + * - add processing of this task to Daemon + * - check JIRA what to do next and how to send the newsletter + * - see \MailPoet\Subscribers\NewSubscriberNotificationMailer how to send an email, now with DI everything should be easy + */ class StatsNotifications { diff --git a/lib/Models/StatsNotification.php b/lib/Models/StatsNotification.php new file mode 100644 index 0000000000..0c2c49522c --- /dev/null +++ b/lib/Models/StatsNotification.php @@ -0,0 +1,9 @@ +