Campaign UI and model adjusted to allow sending a campaign to multiple lists
This commit is contained in:
parent
130c953d94
commit
67d7129f7b
16 changed files with 334 additions and 78 deletions
|
|
@ -51,20 +51,20 @@ async function run() {
|
|||
|
||||
running = true;
|
||||
|
||||
let rssCampaign;
|
||||
let rssCampaignIdRow;
|
||||
|
||||
while (rssCampaign = await knex('campaigns')
|
||||
while (rssCampaignIdRow = await knex('campaigns')
|
||||
.where('type', CampaignType.RSS)
|
||||
.where('status', CampaignStatus.ACTIVE)
|
||||
.where(qry => qry.whereNull('last_check').orWhere('last_check', '<', new Date(Date.now() - feedCheckInterval)))
|
||||
// 'SELECT `id`, `source_url`, `from`, `address`, `subject`, `list`, `segment`, `html`, `open_tracking_disabled`, `click_tracking_disabled`
|
||||
.select('id')
|
||||
.first()) {
|
||||
|
||||
const rssCampaign = campaigns.getById(contextHelpers.getAdminContext(), rssCampaignIdRow.id);
|
||||
|
||||
let checkStatus = null;
|
||||
|
||||
try {
|
||||
rssCampaign.data = JSON.parse(rssCampaign.data);
|
||||
|
||||
const entries = await fetch(rssCampaign.data.feedUrl);
|
||||
|
||||
let added = 0;
|
||||
|
|
@ -95,8 +95,7 @@ async function run() {
|
|||
type: CampaignType.RSS_ENTRY,
|
||||
source,
|
||||
name: entry.title || `RSS entry ${entry.guid.substr(0, 67)}`,
|
||||
list: rssCampaign.list,
|
||||
segment: rssCampaign.segment,
|
||||
lists: rssCampaign.lists,
|
||||
namespace: rssCampaign.namespace,
|
||||
send_configuration: rssCampaign.send_configuration,
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,17 @@
|
|||
'use strict';
|
||||
|
||||
const config = require('config');
|
||||
const fork = require('child_process').fork;
|
||||
const log = require('npmlog');
|
||||
const path = require('path');
|
||||
const knex = require('../lib/knex');
|
||||
|
||||
let messageTid = 0;
|
||||
let workerProcesses = new Map();
|
||||
|
||||
const numOfWorkerProcesses = 5;
|
||||
|
||||
let running = false;
|
||||
|
||||
/*
|
||||
const knex = require('../lib/knex');
|
||||
const path = require('path');
|
||||
const log = require('npmlog');
|
||||
const fsExtra = require('fs-extra-promise');
|
||||
|
|
@ -28,9 +27,16 @@ const shares = require('../models/shares');
|
|||
const _ = require('../lib/translate')._;
|
||||
*/
|
||||
|
||||
|
||||
async function processCampaign(campaignId) {
|
||||
const campaignSubscribersTable = 'campaign__' + campaignId;
|
||||
|
||||
|
||||
}
|
||||
|
||||
async function spawnWorker(workerId) {
|
||||
return await new Promise((resolve, reject) => {
|
||||
log.info('Senders', `Spawning worker process ${workerId}`);
|
||||
log.verbose('Senders', `Spawning worker process ${workerId}`);
|
||||
|
||||
const senderProcess = fork(path.join(__dirname, 'sender-worker.js'), [workerId], {
|
||||
cwd: path.join(__dirname, '..'),
|
||||
|
|
@ -79,7 +85,7 @@ function sendToWorker(workerId, msgType, data) {
|
|||
async function init() {
|
||||
const spawnWorkerFutures = [];
|
||||
let workerId;
|
||||
for (workerId = 0; workerId < numOfWorkerProcesses; workerId++) {
|
||||
for (workerId = 0; workerId < config.queue.processes; workerId++) {
|
||||
spawnWorkerFutures.push(spawnWorker(workerId));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue