- Renames statistics table to the new "statistics_entity" format
- Adds new clicks statistics model
This commit is contained in:
@@ -81,8 +81,9 @@ class Initializer {
|
|||||||
$newsletter_templates = Env::$db_prefix . 'newsletter_templates';
|
$newsletter_templates = Env::$db_prefix . 'newsletter_templates';
|
||||||
$newsletter_option_fields = Env::$db_prefix . 'newsletter_option_fields';
|
$newsletter_option_fields = Env::$db_prefix . 'newsletter_option_fields';
|
||||||
$newsletter_option = Env::$db_prefix . 'newsletter_option';
|
$newsletter_option = Env::$db_prefix . 'newsletter_option';
|
||||||
$newsletter_statistics = Env::$db_prefix . 'newsletter_statistics';
|
|
||||||
$newsletter_links = Env::$db_prefix . 'newsletter_links';
|
$newsletter_links = Env::$db_prefix . 'newsletter_links';
|
||||||
|
$statistics_newsletters = Env::$db_prefix . 'statistics_newsletters';
|
||||||
|
$statistics_clicks = Env::$db_prefix . 'statistics_clicks';
|
||||||
|
|
||||||
define('MP_SETTINGS_TABLE', $settings);
|
define('MP_SETTINGS_TABLE', $settings);
|
||||||
define('MP_SEGMENTS_TABLE', $segments);
|
define('MP_SEGMENTS_TABLE', $segments);
|
||||||
@@ -96,9 +97,10 @@ class Initializer {
|
|||||||
define('MP_NEWSLETTER_TEMPLATES_TABLE', $newsletter_templates);
|
define('MP_NEWSLETTER_TEMPLATES_TABLE', $newsletter_templates);
|
||||||
define('MP_NEWSLETTER_SEGMENT_TABLE', $newsletter_segment);
|
define('MP_NEWSLETTER_SEGMENT_TABLE', $newsletter_segment);
|
||||||
define('MP_NEWSLETTER_OPTION_FIELDS_TABLE', $newsletter_option_fields);
|
define('MP_NEWSLETTER_OPTION_FIELDS_TABLE', $newsletter_option_fields);
|
||||||
define('MP_NEWSLETTER_STATISTICS_TABLE', $newsletter_statistics);
|
|
||||||
define('MP_NEWSLETTER_LINKS_TABLE', $newsletter_links);
|
define('MP_NEWSLETTER_LINKS_TABLE', $newsletter_links);
|
||||||
define('MP_NEWSLETTER_OPTION_TABLE', $newsletter_option);
|
define('MP_NEWSLETTER_OPTION_TABLE', $newsletter_option);
|
||||||
|
define('MP_STATISTICS_NEWSLETTERS_TABLE', $statistics_newsletters);
|
||||||
|
define('MP_STATISTICS_CLICKS_TABLE', $statistics_clicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
function runMigrator() {
|
function runMigrator() {
|
||||||
|
@@ -22,9 +22,10 @@ class Migrator {
|
|||||||
'newsletter_option_fields',
|
'newsletter_option_fields',
|
||||||
'newsletter_option',
|
'newsletter_option',
|
||||||
'newsletter_segment',
|
'newsletter_segment',
|
||||||
'newsletter_statistics',
|
|
||||||
'newsletter_links',
|
'newsletter_links',
|
||||||
'forms'
|
'forms',
|
||||||
|
'statistics_newsletters',
|
||||||
|
'statistics_clicks',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,18 +236,6 @@ class Migrator {
|
|||||||
return $this->sqlify(__FUNCTION__, $attributes);
|
return $this->sqlify(__FUNCTION__, $attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
function newsletter_statistics() {
|
|
||||||
$attributes = array(
|
|
||||||
'id mediumint(9) NOT NULL AUTO_INCREMENT,',
|
|
||||||
'newsletter_id mediumint(9) NOT NULL,',
|
|
||||||
'subscriber_id mediumint(9) NOT NULL,',
|
|
||||||
'queue_id mediumint(9) NOT NULL,',
|
|
||||||
'sent_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,',
|
|
||||||
'PRIMARY KEY (id)',
|
|
||||||
);
|
|
||||||
return $this->sqlify(__FUNCTION__, $attributes);
|
|
||||||
}
|
|
||||||
|
|
||||||
function newsletter_links() {
|
function newsletter_links() {
|
||||||
$attributes = array(
|
$attributes = array(
|
||||||
'id mediumint(9) NOT NULL AUTO_INCREMENT,',
|
'id mediumint(9) NOT NULL AUTO_INCREMENT,',
|
||||||
@@ -276,6 +265,34 @@ class Migrator {
|
|||||||
return $this->sqlify(__FUNCTION__, $attributes);
|
return $this->sqlify(__FUNCTION__, $attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function statistics_newsletters() {
|
||||||
|
$attributes = array(
|
||||||
|
'id mediumint(9) NOT NULL AUTO_INCREMENT,',
|
||||||
|
'newsletter_id mediumint(9) NOT NULL,',
|
||||||
|
'subscriber_id mediumint(9) NOT NULL,',
|
||||||
|
'queue_id mediumint(9) NOT NULL,',
|
||||||
|
'sent_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,',
|
||||||
|
'PRIMARY KEY (id)',
|
||||||
|
);
|
||||||
|
return $this->sqlify(__FUNCTION__, $attributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
function statistics_clicks() {
|
||||||
|
$attributes = array(
|
||||||
|
'id mediumint(9) NOT NULL AUTO_INCREMENT,',
|
||||||
|
'newsletter_id mediumint(9) NOT NULL,',
|
||||||
|
'subscriber_id mediumint(9) NOT NULL,',
|
||||||
|
'queue_id mediumint(9) NOT NULL,',
|
||||||
|
'link_id mediumint(9) NOT NULL,',
|
||||||
|
'count mediumint(9) NOT NULL,',
|
||||||
|
'created_at TIMESTAMP NOT NULL DEFAULT 0,',
|
||||||
|
'deleted_at TIMESTAMP NULL DEFAULT NULL,',
|
||||||
|
'updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,',
|
||||||
|
'PRIMARY KEY (id)',
|
||||||
|
);
|
||||||
|
return $this->sqlify(__FUNCTION__, $attributes);
|
||||||
|
}
|
||||||
|
|
||||||
private function sqlify($model, $attributes) {
|
private function sqlify($model, $attributes) {
|
||||||
$table = $this->prefix . $model;
|
$table = $this->prefix . $model;
|
||||||
|
|
||||||
|
@@ -5,8 +5,8 @@ use MailPoet\Cron\CronHelper;
|
|||||||
use MailPoet\Mailer\Mailer;
|
use MailPoet\Mailer\Mailer;
|
||||||
use MailPoet\Models\Newsletter;
|
use MailPoet\Models\Newsletter;
|
||||||
use MailPoet\Models\NewsletterLink;
|
use MailPoet\Models\NewsletterLink;
|
||||||
use MailPoet\Models\NewsletterStatistics;
|
|
||||||
use MailPoet\Models\Setting;
|
use MailPoet\Models\Setting;
|
||||||
|
use MailPoet\Models\StatisticsNewsletters;
|
||||||
use MailPoet\Models\Subscriber;
|
use MailPoet\Models\Subscriber;
|
||||||
use MailPoet\Newsletter\Links\Links;
|
use MailPoet\Newsletter\Links\Links;
|
||||||
use MailPoet\Newsletter\Renderer\Renderer;
|
use MailPoet\Newsletter\Renderer\Renderer;
|
||||||
@@ -166,7 +166,7 @@ class SendingQueue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateNewsletterStatistics($data) {
|
function updateNewsletterStatistics($data) {
|
||||||
return NewsletterStatistics::createMultiple($data);
|
return StatisticsNewsletters::createMultiple($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderNewsletter($newsletter) {
|
function renderNewsletter($newsletter) {
|
||||||
|
@@ -3,22 +3,10 @@ namespace MailPoet\Models;
|
|||||||
|
|
||||||
if(!defined('ABSPATH')) exit;
|
if(!defined('ABSPATH')) exit;
|
||||||
|
|
||||||
class StatisticsNewsletters extends Model {
|
class StatisticsClicks extends Model {
|
||||||
public static $_table = MP_STATISTICS_NEWSLETTERS_TABLE;
|
public static $_table = MP_STATISTICS_CLICKS_TABLE;
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
static function createMultiple($data) {
|
|
||||||
return self::rawExecute(
|
|
||||||
'INSERT INTO `' . self::$_table . '` ' .
|
|
||||||
'(newsletter_id, subscriber_id, queue_id) ' .
|
|
||||||
'VALUES ' . rtrim(
|
|
||||||
str_repeat('(?,?,?), ', count($data)/3),
|
|
||||||
', '
|
|
||||||
),
|
|
||||||
$data
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
7
lib/Statistics/Track/Clicks.php
Normal file
7
lib/Statistics/Track/Clicks.php
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
namespace MailPoet\Cron;
|
||||||
|
|
||||||
|
if(!defined('ABSPATH')) exit;
|
||||||
|
|
||||||
|
class Clicks {
|
||||||
|
}
|
Reference in New Issue
Block a user