Fixed stats for welcome emails
- re-added ORM logging in order to debug queries - fixed subscription confirmation / unsubscribe due to API refactor
This commit is contained in:
@ -10,6 +10,7 @@ class Subscription {
|
|||||||
|
|
||||||
static function confirm($data) {
|
static function confirm($data) {
|
||||||
$subscription = new UserSubscription\Pages('confirm', $data);
|
$subscription = new UserSubscription\Pages('confirm', $data);
|
||||||
|
$subscription->confirm();
|
||||||
}
|
}
|
||||||
|
|
||||||
static function manage($data) {
|
static function manage($data) {
|
||||||
@ -18,5 +19,6 @@ class Subscription {
|
|||||||
|
|
||||||
static function unsubscribe($data) {
|
static function unsubscribe($data) {
|
||||||
$subscription = new UserSubscription\Pages('unsubscribe', $data);
|
$subscription = new UserSubscription\Pages('unsubscribe', $data);
|
||||||
|
$subscription->unsubscribe();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -56,6 +56,7 @@ class Initializer {
|
|||||||
\ORM::configure(Env::$db_source_name);
|
\ORM::configure(Env::$db_source_name);
|
||||||
\ORM::configure('username', Env::$db_username);
|
\ORM::configure('username', Env::$db_username);
|
||||||
\ORM::configure('password', Env::$db_password);
|
\ORM::configure('password', Env::$db_password);
|
||||||
|
\ORM::configure('logging', WP_DEBUG);
|
||||||
\ORM::configure('driver_options', array(
|
\ORM::configure('driver_options', array(
|
||||||
\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
|
\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
|
||||||
\PDO::MYSQL_ATTR_INIT_COMMAND =>
|
\PDO::MYSQL_ATTR_INIT_COMMAND =>
|
||||||
|
@ -189,37 +189,66 @@ class Newsletter extends Model {
|
|||||||
} else {
|
} else {
|
||||||
$this->statistics = $statistics->asArray();
|
$this->statistics = $statistics->asArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStatistics() {
|
function getStatistics() {
|
||||||
if($this->queue === false) {
|
switch($this->type) {
|
||||||
return false;
|
case self::TYPE_WELCOME:
|
||||||
|
return SendingQueue::tableAlias('queues')
|
||||||
|
->selectExpr(
|
||||||
|
'COUNT(DISTINCT(clicks.subscriber_id)) as clicked, ' .
|
||||||
|
'COUNT(DISTINCT(opens.subscriber_id)) as opened, ' .
|
||||||
|
'COUNT(DISTINCT(unsubscribes.subscriber_id)) as unsubscribed '
|
||||||
|
)
|
||||||
|
->leftOuterJoin(
|
||||||
|
MP_STATISTICS_CLICKS_TABLE,
|
||||||
|
'queues.id = clicks.queue_id',
|
||||||
|
'clicks'
|
||||||
|
)
|
||||||
|
->leftOuterJoin(
|
||||||
|
MP_STATISTICS_OPENS_TABLE,
|
||||||
|
'queues.id = opens.queue_id',
|
||||||
|
'opens'
|
||||||
|
)
|
||||||
|
->leftOuterJoin(
|
||||||
|
MP_STATISTICS_UNSUBSCRIBES_TABLE,
|
||||||
|
'queues.id = unsubscribes.queue_id',
|
||||||
|
'unsubscribes'
|
||||||
|
)
|
||||||
|
->where('queues.newsletter_id', $this->id)
|
||||||
|
->where('queues.status', SendingQueue::STATUS_COMPLETED)
|
||||||
|
->findOne();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
if($this->queue === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return SendingQueue::tableAlias('queues')
|
||||||
|
->selectExpr(
|
||||||
|
'COUNT(DISTINCT(clicks.subscriber_id)) as clicked, ' .
|
||||||
|
'COUNT(DISTINCT(opens.subscriber_id)) as opened, ' .
|
||||||
|
'COUNT(DISTINCT(unsubscribes.subscriber_id)) as unsubscribed '
|
||||||
|
)
|
||||||
|
->leftOuterJoin(
|
||||||
|
MP_STATISTICS_CLICKS_TABLE,
|
||||||
|
'queues.id = clicks.queue_id',
|
||||||
|
'clicks'
|
||||||
|
)
|
||||||
|
->leftOuterJoin(
|
||||||
|
MP_STATISTICS_OPENS_TABLE,
|
||||||
|
'queues.id = opens.queue_id',
|
||||||
|
'opens'
|
||||||
|
)
|
||||||
|
->leftOuterJoin(
|
||||||
|
MP_STATISTICS_UNSUBSCRIBES_TABLE,
|
||||||
|
'queues.id = unsubscribes.queue_id',
|
||||||
|
'unsubscribes'
|
||||||
|
)
|
||||||
|
->where('queues.id', $this->queue['id'])
|
||||||
|
->findOne();
|
||||||
}
|
}
|
||||||
return SendingQueue::tableAlias('queues')
|
|
||||||
->selectExpr(
|
|
||||||
'COUNT(DISTINCT(clicks.subscriber_id)) as clicked, ' .
|
|
||||||
'COUNT(DISTINCT(opens.subscriber_id)) as opened, ' .
|
|
||||||
'COUNT(DISTINCT(unsubscribes.subscriber_id)) as unsubscribed '
|
|
||||||
)
|
|
||||||
->leftOuterJoin(
|
|
||||||
MP_STATISTICS_CLICKS_TABLE,
|
|
||||||
'queues.id = clicks.queue_id',
|
|
||||||
'clicks'
|
|
||||||
)
|
|
||||||
->leftOuterJoin(
|
|
||||||
MP_STATISTICS_OPENS_TABLE,
|
|
||||||
'queues.id = opens.queue_id',
|
|
||||||
'opens'
|
|
||||||
)
|
|
||||||
->leftOuterJoin(
|
|
||||||
MP_STATISTICS_UNSUBSCRIBES_TABLE,
|
|
||||||
'queues.id = unsubscribes.queue_id',
|
|
||||||
'unsubscribes'
|
|
||||||
)
|
|
||||||
->where('queues.id', $this->queue['id'])
|
|
||||||
->findOne();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static function search($orm, $search = '') {
|
static function search($orm, $search = '') {
|
||||||
|
Reference in New Issue
Block a user