- Displays statistics in newsletter listing
This commit is contained in:
committed by
Tautvidas Sipavičius
parent
67ca305b7f
commit
18f35b5e91
@ -16,7 +16,7 @@ define(
|
|||||||
MailPoet
|
MailPoet
|
||||||
) {
|
) {
|
||||||
var Link = Router.Link;
|
var Link = Router.Link;
|
||||||
|
console.log(MailPoet)
|
||||||
var columns = [
|
var columns = [
|
||||||
{
|
{
|
||||||
name: 'subject',
|
name: 'subject',
|
||||||
@ -31,6 +31,10 @@ define(
|
|||||||
name: 'segments',
|
name: 'segments',
|
||||||
label: MailPoet.I18n.t('lists')
|
label: MailPoet.I18n.t('lists')
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'statistics',
|
||||||
|
label: MailPoet.I18n.t('statistics')
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'created_at',
|
name: 'created_at',
|
||||||
label: MailPoet.I18n.t('createdOn'),
|
label: MailPoet.I18n.t('createdOn'),
|
||||||
@ -205,6 +209,31 @@ define(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
renderStatistics: function(item) {
|
||||||
|
if(!item.statistics || !item.queue) {
|
||||||
|
return (
|
||||||
|
<span>
|
||||||
|
{MailPoet.I18n.t('notSentYet')}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
var percentage_clicked = Math.round(
|
||||||
|
(item.statistics.clicked * 100) / (item.queue.count_processed)
|
||||||
|
);
|
||||||
|
var percentage_opened = Math.round(
|
||||||
|
(item.statistics.opened * 100) / (item.queue.count_processed)
|
||||||
|
);
|
||||||
|
var percentage_unsubscribed = Math.round(
|
||||||
|
(item.statistics.unsubscribed * 100) / (item.queue.count_processed)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<span>
|
||||||
|
{ percentage_opened }%, { percentage_clicked }%, { percentage_unsubscribed }%
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
},
|
||||||
renderItem: function(newsletter, actions) {
|
renderItem: function(newsletter, actions) {
|
||||||
var rowClasses = classNames(
|
var rowClasses = classNames(
|
||||||
'manage-column',
|
'manage-column',
|
||||||
@ -216,6 +245,13 @@ define(
|
|||||||
return segment.name
|
return segment.name
|
||||||
}).join(', ');
|
}).join(', ');
|
||||||
|
|
||||||
|
var statistics_column =
|
||||||
|
(!mailpoet_settings.tracking || !mailpoet_settings.tracking.enabled) ?
|
||||||
|
false :
|
||||||
|
<td className="column {statistics_class}" data-colname="Statistics">
|
||||||
|
{ this.renderStatistics(newsletter) }
|
||||||
|
</td>;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<td className={ rowClasses }>
|
<td className={ rowClasses }>
|
||||||
@ -224,12 +260,13 @@ define(
|
|||||||
</strong>
|
</strong>
|
||||||
{ actions }
|
{ actions }
|
||||||
</td>
|
</td>
|
||||||
<td className="column" data-colname="Lists">
|
<td className="column" data-colname="Status">
|
||||||
{ this.renderStatus(newsletter) }
|
{ this.renderStatus(newsletter) }
|
||||||
</td>
|
</td>
|
||||||
<td className="column" data-colname="Lists">
|
<td className="column" data-colname="Lists">
|
||||||
{ segments }
|
{ segments }
|
||||||
</td>
|
</td>
|
||||||
|
{ statistics_column }
|
||||||
<td className="column-date" data-colname="Subscribed on">
|
<td className="column-date" data-colname="Subscribed on">
|
||||||
<abbr>{ MailPoet.Date.full(newsletter.created_at) }</abbr>
|
<abbr>{ MailPoet.Date.full(newsletter.created_at) }</abbr>
|
||||||
</td>
|
</td>
|
||||||
@ -240,6 +277,9 @@ define(
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
|
if (!mailpoet_settings.tracking || !mailpoet_settings.tracking.enabled) {
|
||||||
|
columns = _.without(columns, _.findWhere(columns, {name: 'statistics'}));
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h2 className="title">
|
<h2 className="title">
|
||||||
|
@ -94,15 +94,14 @@ class Newsletter extends Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getStatistics() {
|
function getStatistics() {
|
||||||
if (!property_exists($this, 'queue') || $this->queue === false) {
|
if ($this->queue === false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return SendingQueue::tableAlias('queues')
|
return SendingQueue::tableAlias('queues')
|
||||||
->selectExpr(
|
->selectExpr(
|
||||||
'count(DISTINCT(clicks.id)) as clicks, ' .
|
'count(DISTINCT(clicks.id)) as clicked, ' .
|
||||||
'count(DISTINCT(opens.id)) as opens, ' .
|
'count(DISTINCT(opens.id)) as opened, ' .
|
||||||
'count(DISTINCT(unsubscribes.id)) as unsubscribes',
|
'count(DISTINCT(unsubscribes.id)) as unsubscribed '
|
||||||
'queues.count_processed as total_sent'
|
|
||||||
)
|
)
|
||||||
->join(
|
->join(
|
||||||
MP_STATISTICS_CLICKS_TABLE,
|
MP_STATISTICS_CLICKS_TABLE,
|
||||||
|
@ -203,11 +203,13 @@ class Newsletters {
|
|||||||
$listing_data = $listing->get();
|
$listing_data = $listing->get();
|
||||||
|
|
||||||
foreach($listing_data['items'] as $key => $newsletter) {
|
foreach($listing_data['items'] as $key => $newsletter) {
|
||||||
$listing_data['items'][$key] = $newsletter
|
$newsletter = $newsletter
|
||||||
->withSegments()
|
->withSegments()
|
||||||
->withSendingQueue()
|
->withSendingQueue();
|
||||||
->withStatistics()
|
if((boolean) Setting::getValue('tracking.enabled')) {
|
||||||
->asArray();
|
$newsletter = $newsletter->withStatistics();
|
||||||
|
}
|
||||||
|
$listing_data['items'][$key] = $newsletter->asArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $listing_data;
|
return $listing_data;
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
|
|
||||||
'subject': __('Subject'),
|
'subject': __('Subject'),
|
||||||
'status': __('Status'),
|
'status': __('Status'),
|
||||||
|
'statistics': __('Opened, Clicked, Unsubscribed'),
|
||||||
'lists': __('Lists'),
|
'lists': __('Lists'),
|
||||||
'createdOn': __('Created on'),
|
'createdOn': __('Created on'),
|
||||||
'lastModifiedOn': __('Last modified on'),
|
'lastModifiedOn': __('Last modified on'),
|
||||||
|
Reference in New Issue
Block a user