Exported CSV now contains status column (fix for #547)
This commit is contained in:
parent
0c3510d626
commit
41cd01c2b9
2 changed files with 12 additions and 1 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit d260de2e153f9c1d6bc7af69c1c3d733073bab74
|
Subproject commit f0167635c8c238e828b311fa9d0b058b5a00020d
|
|
@ -10,8 +10,16 @@ const stringify = require('csv-stringify')
|
||||||
const fields = require('../models/fields');
|
const fields = require('../models/fields');
|
||||||
const lists = require('../models/lists');
|
const lists = require('../models/lists');
|
||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
|
const {SubscriptionStatus} = require('../../shared/lists');
|
||||||
|
|
||||||
router.getAsync('/export/:listId/:segmentId', passport.loggedIn, async (req, res) => {
|
router.getAsync('/export/:listId/:segmentId', passport.loggedIn, async (req, res) => {
|
||||||
|
const statusStrings = {
|
||||||
|
[SubscriptionStatus.SUBSCRIBED]: 'subscribed',
|
||||||
|
[SubscriptionStatus.UNSUBSCRIBED]: 'unsubscribed',
|
||||||
|
[SubscriptionStatus.BOUNCED]: 'bounced',
|
||||||
|
[SubscriptionStatus.COMPLAINED]: 'complained'
|
||||||
|
};
|
||||||
|
|
||||||
const listId = castToInteger(req.params.listId);
|
const listId = castToInteger(req.params.listId);
|
||||||
const segmentId = castToInteger(req.params.segmentId);
|
const segmentId = castToInteger(req.params.segmentId);
|
||||||
|
|
||||||
|
@ -19,6 +27,7 @@ router.getAsync('/export/:listId/:segmentId', passport.loggedIn, async (req, res
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{key: 'cid', header: 'cid'},
|
{key: 'cid', header: 'cid'},
|
||||||
|
{key: 'status', header: 'status'},
|
||||||
{key: 'hash_email', header: 'HASH_EMAIL'},
|
{key: 'hash_email', header: 'HASH_EMAIL'},
|
||||||
{key: 'email', header: 'EMAIL'},
|
{key: 'email', header: 'EMAIL'},
|
||||||
];
|
];
|
||||||
|
@ -50,6 +59,8 @@ router.getAsync('/export/:listId/:segmentId', passport.loggedIn, async (req, res
|
||||||
stringifier.pipe(res);
|
stringifier.pipe(res);
|
||||||
|
|
||||||
for await (const subscription of subscriptions.listIterator(req.context, listId, segmentId, false)) {
|
for await (const subscription of subscriptions.listIterator(req.context, listId, segmentId, false)) {
|
||||||
|
subscription.status = statusStrings[subscription.status];
|
||||||
|
|
||||||
stringifier.write(subscription);
|
stringifier.write(subscription);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue