Some preparations for activity log.
Fixed issue #524 Table now displays horizontal scrollbar when the viewport is too narrow (typically on mobile)
This commit is contained in:
parent
4f408a26d5
commit
e0bee9ed42
28 changed files with 353 additions and 97 deletions
55
server/lib/activity-log.js
Normal file
55
server/lib/activity-log.js
Normal file
|
@ -0,0 +1,55 @@
|
|||
'use strict';
|
||||
|
||||
async function _logActivity(typeId, data) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
/*
|
||||
Extra data:
|
||||
|
||||
campaign:
|
||||
- status : CampaignStatus
|
||||
|
||||
list:
|
||||
- subscriptionId
|
||||
- subscriptionStatus : SubscriptionStatus
|
||||
- fieldId
|
||||
- segmentId
|
||||
- importId
|
||||
- importStatus : ImportStatus
|
||||
*/
|
||||
async function logEntityActivity(entityTypeId, activityType, entityId, extraData = {}) {
|
||||
const data = {
|
||||
...extraData,
|
||||
type: activityType,
|
||||
entity: entityId
|
||||
};
|
||||
|
||||
await _logActivity(entityTypeId, data);
|
||||
}
|
||||
|
||||
async function logCampaignTrackerActivity(activityType, campaignId, listId, subscriptionId, extraData = {}) {
|
||||
const data = {
|
||||
...extraData,
|
||||
type: activityType,
|
||||
campaign: campaignId,
|
||||
list: listId,
|
||||
subscription: subscriptionId
|
||||
};
|
||||
|
||||
await _logActivity('campaign_tracker', data);
|
||||
}
|
||||
|
||||
async function logBlacklistActivity(activityType, email) {
|
||||
const data = {
|
||||
...extraData,
|
||||
type: activityType,
|
||||
email
|
||||
};
|
||||
|
||||
await _logActivity('blacklist', data);
|
||||
}
|
||||
|
||||
module.exports.logEntityActivity = logEntityActivity;
|
||||
module.exports.logBlacklistActivity = logBlacklistActivity;
|
||||
module.exports.logCampaignTrackerActivity = logCampaignTrackerActivity;
|
|
@ -5,6 +5,8 @@ const fork = require('child_process').fork;
|
|||
const log = require('./log');
|
||||
const path = require('path');
|
||||
const {ImportStatus, RunStatus} = require('../../shared/imports');
|
||||
const {ListActivityType} = require('../../shared/activity-log');
|
||||
const activityLog = require('./activity-log');
|
||||
|
||||
let messageTid = 0;
|
||||
let importerProcess;
|
||||
|
@ -18,11 +20,17 @@ function spawn(callback) {
|
|||
log.verbose('Importer', 'Spawning importer process');
|
||||
|
||||
knex.transaction(async tx => {
|
||||
await tx('imports').where('status', ImportStatus.PREP_RUNNING).update({status: ImportStatus.PREP_SCHEDULED});
|
||||
await tx('imports').where('status', ImportStatus.PREP_STOPPING).update({status: ImportStatus.PREP_FAILED});
|
||||
const updateStatus = async (fromStatus, toStatus) => {
|
||||
for (const impt of await tx('imports').where('status', fromStatus).select(['id', 'list'])) {
|
||||
await tx('imports').where('id', impt.id).update({status: toStatus});
|
||||
await activityLog.logEntityActivity('list', ListActivityType.IMPORT_STATUS_CHANGE, impt.list, {importId: impt.id, importStatus: toStatus});
|
||||
}
|
||||
}
|
||||
|
||||
await tx('imports').where('status', ImportStatus.RUN_RUNNING).update({status: ImportStatus.RUN_SCHEDULED});
|
||||
await tx('imports').where('status', ImportStatus.RUN_STOPPING).update({status: ImportStatus.RUN_FAILED});
|
||||
await updateStatus(ImportStatus.PREP_RUNNING, ImportStatus.PREP_SCHEDULED);
|
||||
await updateStatus(ImportStatus.PREP_STOPPING, ImportStatus.PREP_FAILED);
|
||||
await updateStatus(ImportStatus.RUN_RUNNING, ImportStatus.RUN_SCHEDULED);
|
||||
await updateStatus(ImportStatus.RUN_STOPPING, ImportStatus.RUN_FAILED);
|
||||
|
||||
await tx('import_runs').where('status', RunStatus.RUNNING).update({status: RunStatus.SCHEDULED});
|
||||
await tx('import_runs').where('status', RunStatus.STOPPING).update({status: RunStatus.FAILED});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue