diff --git a/client/src/campaigns/triggers/CUD.js b/client/src/campaigns/triggers/CUD.js index 37b9d3f8..01e55e90 100644 --- a/client/src/campaigns/triggers/CUD.js +++ b/client/src/campaigns/triggers/CUD.js @@ -54,6 +54,7 @@ export default class CUD extends Component { this.eventOptions = { [Entity.SUBSCRIPTION]: [ {key: SubscriptionEvent.CREATED, label: eventLabels[Entity.SUBSCRIPTION][SubscriptionEvent.CREATED]}, + {key: SubscriptionEvent.UPDATED, label: eventLabels[Entity.SUBSCRIPTION][SubscriptionEvent.UPDATED]}, {key: SubscriptionEvent.LATEST_OPEN, label: eventLabels[Entity.SUBSCRIPTION][SubscriptionEvent.LATEST_OPEN]}, {key: SubscriptionEvent.LATEST_CLICK, label: eventLabels[Entity.SUBSCRIPTION][SubscriptionEvent.LATEST_CLICK]} ], diff --git a/client/src/campaigns/triggers/helpers.js b/client/src/campaigns/triggers/helpers.js index f170fb71..5cf83081 100644 --- a/client/src/campaigns/triggers/helpers.js +++ b/client/src/campaigns/triggers/helpers.js @@ -15,6 +15,7 @@ export function getTriggerTypes(t) { const eventLabels = { [Entity.SUBSCRIPTION]: { [SubscriptionEvent.CREATED]: t('created'), + [SubscriptionEvent.UPDATED]: t('updated'), [SubscriptionEvent.LATEST_OPEN]: t('latestOpen'), [SubscriptionEvent.LATEST_CLICK]: t('latestClick') }, diff --git a/locales/en-US/common.json b/locales/en-US/common.json index e47722b8..81cb40b0 100644 --- a/locales/en-US/common.json +++ b/locales/en-US/common.json @@ -145,6 +145,7 @@ "addList": "Add list", "type": "Type", "created": "Created", + "updated": "Updated", "override": "Override", "fromName": "\"From\" name", "fromEmailAddress": "\"From\" email address", diff --git a/mvis/ivis-core b/mvis/ivis-core index 5ea4783f..7d15f154 160000 --- a/mvis/ivis-core +++ b/mvis/ivis-core @@ -1 +1 @@ -Subproject commit 5ea4783f3ec5140ad68637c31e230a410e493170 +Subproject commit 7d15f154c933c4789d6c9b288fbdf7437be3d856 diff --git a/server/models/lists.js b/server/models/lists.js index da6f42f2..1095a2b8 100644 --- a/server/models/lists.js +++ b/server/models/lists.js @@ -195,6 +195,7 @@ async function create(context, entity) { ' `latest_open` timestamp NULL DEFAULT NULL,\n' + ' `latest_click` timestamp NULL DEFAULT NULL,\n' + ' `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n' + + ' `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n' + ' PRIMARY KEY (`id`),\n' + ' UNIQUE KEY `hash_email` (`hash_email`),\n' + ' UNIQUE KEY `cid` (`cid`),\n' + @@ -204,7 +205,8 @@ async function create(context, entity) { ' KEY `is_test` (`is_test`),\n' + ' KEY `latest_open` (`latest_open`),\n' + ' KEY `latest_click` (`latest_click`),\n' + - ' KEY `created` (`created`)\n' + + ' KEY `created` (`created`),\n' + + ' KEY `updated` (`updated`)\n' + ') ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;\n'); await shares.rebuildPermissionsTx(tx, { entityTypeId: 'list', entityId: id }); diff --git a/server/models/subscriptions.js b/server/models/subscriptions.js index 06450f0c..f24f0d3f 100644 --- a/server/models/subscriptions.js +++ b/server/models/subscriptions.js @@ -616,6 +616,7 @@ async function _update(tx, listId, groupedFieldsMap, existing, filteredEntity) { } if (filteredEntity) { + filteredEntity.updated = new Date(); await tx(getSubscriptionTableName(listId)).where('id', existing.id).update(filteredEntity); if ('status' in filteredEntity) { diff --git a/server/setup/knex/migrations/20191007120000_add_updated_to_subscriptions.js b/server/setup/knex/migrations/20191007120000_add_updated_to_subscriptions.js new file mode 100644 index 00000000..3a889cbd --- /dev/null +++ b/server/setup/knex/migrations/20191007120000_add_updated_to_subscriptions.js @@ -0,0 +1,10 @@ +exports.up = (knex, Promise) => (async() => { + const lists = await knex('lists'); + for (const list of lists) { + await knex.schema.raw('ALTER TABLE `subscription__' + list.id + '` ADD COLUMN `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER `created`'); + await knex.schema.raw('CREATE INDEX updated ON `subscription__' + list.id + '` (`updated`)'); + } +})(); + +exports.down = (knex, Promise) => (async() => { +})(); diff --git a/shared/triggers.js b/shared/triggers.js index 694d5ef3..5ce01efa 100644 --- a/shared/triggers.js +++ b/shared/triggers.js @@ -8,6 +8,7 @@ const Entity = { const Event = { [Entity.SUBSCRIPTION]: { CREATED: 'created', + UPDATED: 'updated', LATEST_OPEN: 'latest_open', LATEST_CLICK: 'latest_click' }, @@ -28,6 +29,7 @@ const EntityVals = { const EventVals = { [Entity.SUBSCRIPTION]: { created: 'CREATED', + updated: 'UPDATED', latest_open: 'LATEST_OPEN', latest_click: 'LATEST_CLICK' }, @@ -45,4 +47,4 @@ module.exports = { Event, EntityVals, EventVals -}; \ No newline at end of file +};