Date/time and device type in quick report.
Fix - invalid campaign when one tried to unsubscribe from a test message before campaign was sent
This commit is contained in:
parent
2e4dc1bce4
commit
b6ed5e56b9
4 changed files with 13 additions and 7 deletions
|
@ -20,7 +20,7 @@ export default class List extends Component {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h2>{t('Mailtrain 2 beta')}</h2>
|
<h2>{t('Mailtrain 2 beta')}</h2>
|
||||||
<div>{t('Build') + ' 2019-08-31-1200'}</div>
|
<div>{t('Build') + ' 2019-09-05-1547'}</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -769,11 +769,9 @@ async function changeStatusByCampaignCidAndSubscriptionIdTx(tx, context, campaig
|
||||||
])
|
])
|
||||||
.first();
|
.first();
|
||||||
|
|
||||||
if (!message) {
|
if (message) { // If a test is send before the campaign is sent, the corresponding entry does not exists in campaign_messages. We ignore such situations as the subscriber gets unsubscribed anyway. We just don't account it to the campaign.
|
||||||
throw new Error('Invalid campaign.');
|
await _changeStatusByMessageTx(tx, context, message, campaignMessageStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
await _changeStatusByMessageTx(tx, context, message, campaignMessageStatus);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -236,6 +236,8 @@ async function _getCampaignStatistics(campaign, select, joins, unionQryFn, listQ
|
||||||
commonFieldsMapping[`${prefix}:link`] = alias + '.link';
|
commonFieldsMapping[`${prefix}:link`] = alias + '.link';
|
||||||
commonFieldsMapping[`${prefix}:country`] = alias + '.country';
|
commonFieldsMapping[`${prefix}:country`] = alias + '.country';
|
||||||
commonFieldsMapping[`${prefix}:deviceType`] = alias + '.device_type';
|
commonFieldsMapping[`${prefix}:deviceType`] = alias + '.device_type';
|
||||||
|
commonFieldsMapping[`${prefix}:ip`] = alias + '.ip';
|
||||||
|
commonFieldsMapping[`${prefix}:created`] = alias + '.created';
|
||||||
|
|
||||||
knexJoinFns.push((qry, cpgListId) => qry.leftJoin('campaign_links AS ' + alias, getConds(alias, cpgListId)));
|
knexJoinFns.push((qry, cpgListId) => qry.leftJoin('campaign_links AS ' + alias, getConds(alias, cpgListId)));
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ const {castToInteger} = require('../lib/helpers');
|
||||||
const {SubscriptionStatus} = require('../../shared/lists');
|
const {SubscriptionStatus} = require('../../shared/lists');
|
||||||
const knex = require('../lib/knex');
|
const knex = require('../lib/knex');
|
||||||
const {LinkId} = require('../models/links');
|
const {LinkId} = require('../models/links');
|
||||||
|
const moment = require('moment');
|
||||||
|
|
||||||
const router = require('../lib/router-async').create();
|
const router = require('../lib/router-async').create();
|
||||||
|
|
||||||
|
@ -23,7 +24,7 @@ router.getAsync('/open-and-click-counts/:campaignId', passport.loggedIn, async (
|
||||||
|
|
||||||
const results = await reports.getCampaignStatisticsStream(
|
const results = await reports.getCampaignStatisticsStream(
|
||||||
campaign,
|
campaign,
|
||||||
['subscription:email', 'open_tracker:count', 'click_tracker:count', 'open_tracker:country', ...Object.keys(listFields)],
|
['subscription:email', 'open_tracker:count', 'click_tracker:count', 'open_tracker:country', 'open_tracker:created', 'open_tracker:deviceType', ...Object.keys(listFields)],
|
||||||
[
|
[
|
||||||
{type: 'links', prefix: 'open_tracker', onConditions: {link: knex.raw('?', [LinkId.OPEN])} },
|
{type: 'links', prefix: 'open_tracker', onConditions: {link: knex.raw('?', [LinkId.OPEN])} },
|
||||||
{type: 'links', prefix: 'click_tracker', onConditions: {link: knex.raw('?', [LinkId.GENERAL_CLICK])} }
|
{type: 'links', prefix: 'click_tracker', onConditions: {link: knex.raw('?', [LinkId.GENERAL_CLICK])} }
|
||||||
|
@ -48,11 +49,16 @@ router.getAsync('/open-and-click-counts/:campaignId', passport.loggedIn, async (
|
||||||
{ key: 'open_tracker:count', header: 'Open count' },
|
{ key: 'open_tracker:count', header: 'Open count' },
|
||||||
{ key: 'click_tracker:count', header: 'Click count' },
|
{ key: 'click_tracker:count', header: 'Click count' },
|
||||||
{ key: 'open_tracker:country', header: 'Country (first open)' },
|
{ key: 'open_tracker:country', header: 'Country (first open)' },
|
||||||
|
{ key: 'open_tracker:created', header: 'Date/time (first open)' },
|
||||||
|
{ key: 'open_tracker:deviceType', header: 'Device type (first open)' },
|
||||||
...Object.keys(listFields).map(key => ({key, header: listFields[key].key}))
|
...Object.keys(listFields).map(key => ({key, header: listFields[key].key}))
|
||||||
],
|
],
|
||||||
delimiter: ','
|
delimiter: ','
|
||||||
},
|
},
|
||||||
async (row, encoding) => row
|
async (row, encoding) => ({
|
||||||
|
...row,
|
||||||
|
'open_tracker:created': moment(row['open_tracker:created']).toISOString()
|
||||||
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue