Merge pull request #131 from djKooks/const_patch
Change certain values to const
This commit is contained in:
commit
1513c761bc
4 changed files with 19 additions and 14 deletions
|
@ -10,9 +10,10 @@ let campaigns = require('../lib/models/campaigns');
|
||||||
function feedLoop() {
|
function feedLoop() {
|
||||||
|
|
||||||
db.getConnection((err, connection) => {
|
db.getConnection((err, connection) => {
|
||||||
|
const feed_timeout = 15 * 1000;
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error('Feed', err.stack);
|
log.error('Feed', err.stack);
|
||||||
return setTimeout(feedLoop, 15 * 1000);
|
return setTimeout(feedLoop, feed_timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
let query = 'SELECT `id`, `source_url`, `from`, `address`, `subject`, `list`, `segment`, `html` FROM `campaigns` WHERE `type`=2 AND `status`=6 AND (`last_check` IS NULL OR `last_check`< NOW() - INTERVAL 10 MINUTE) LIMIT 1';
|
let query = 'SELECT `id`, `source_url`, `from`, `address`, `subject`, `list`, `segment`, `html` FROM `campaigns` WHERE `type`=2 AND `status`=6 AND (`last_check` IS NULL OR `last_check`< NOW() - INTERVAL 10 MINUTE) LIMIT 1';
|
||||||
|
@ -21,22 +22,23 @@ function feedLoop() {
|
||||||
connection.release();
|
connection.release();
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error('Feed', err);
|
log.error('Feed', err);
|
||||||
return setTimeout(feedLoop, 15 * 1000);
|
return setTimeout(feedLoop, feed_timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rows || !rows.length) {
|
if (!rows || !rows.length) {
|
||||||
return setTimeout(feedLoop, 15 * 1000);
|
return setTimeout(feedLoop, feed_timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
let parent = tools.convertKeys(rows[0]);
|
let parent = tools.convertKeys(rows[0]);
|
||||||
|
|
||||||
updateRssInfo(parent.id, true, false, () => {
|
updateRssInfo(parent.id, true, false, () => {
|
||||||
|
const rss_timeout = 1 * 1000;
|
||||||
log.verbose('Feed', 'Checking feed %s (%s)', parent.sourceUrl, parent.id);
|
log.verbose('Feed', 'Checking feed %s (%s)', parent.sourceUrl, parent.id);
|
||||||
feed.fetch(parent.sourceUrl, (err, entries) => {
|
feed.fetch(parent.sourceUrl, (err, entries) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error('Feed', err);
|
log.error('Feed', err);
|
||||||
return updateRssInfo(parent.id, false, 'Feed error: ' + err.message, () => {
|
return updateRssInfo(parent.id, false, 'Feed error: ' + err.message, () => {
|
||||||
setTimeout(feedLoop, 1 * 1000);
|
setTimeout(feedLoop, rss_timeout);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
checkEntries(parent, entries, (err, result) => {
|
checkEntries(parent, entries, (err, result) => {
|
||||||
|
@ -51,7 +53,7 @@ function feedLoop() {
|
||||||
message = 'Found nothing new from the feed';
|
message = 'Found nothing new from the feed';
|
||||||
}
|
}
|
||||||
return updateRssInfo(parent.id, false, message, () => {
|
return updateRssInfo(parent.id, false, message, () => {
|
||||||
setTimeout(feedLoop, 1 * 1000);
|
setTimeout(feedLoop, rss_timeout);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -221,15 +221,16 @@ function processImport(data, callback) {
|
||||||
|
|
||||||
let importLoop = () => {
|
let importLoop = () => {
|
||||||
let getNext = () => {
|
let getNext = () => {
|
||||||
|
const process_timout = 5 * 1000;
|
||||||
// find an unsent message
|
// find an unsent message
|
||||||
findUnprocessed((err, data) => {
|
findUnprocessed((err, data) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error('Import', err.stack);
|
log.error('Import', err.stack);
|
||||||
setTimeout(getNext, 5 * 1000);
|
setTimeout(getNext, process_timout);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!data) {
|
if (!data) {
|
||||||
setTimeout(getNext, 5 * 1000);
|
setTimeout(getNext, process_timout);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,7 +247,7 @@ let importLoop = () => {
|
||||||
db.getConnection((err, connection) => {
|
db.getConnection((err, connection) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error('Import', err.stack);
|
log.error('Import', err.stack);
|
||||||
return setTimeout(getNext, 5 * 1000);
|
return setTimeout(getNext, process_timout);
|
||||||
}
|
}
|
||||||
|
|
||||||
let query = 'UPDATE importer SET `status`=?, `error`=?, `finished`=NOW() WHERE `id`=? AND `status`=2 LIMIT 1';
|
let query = 'UPDATE importer SET `status`=?, `error`=?, `finished`=NOW() WHERE `id`=? AND `status`=2 LIMIT 1';
|
||||||
|
|
|
@ -461,6 +461,7 @@ let sendLoop = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
let getNext = () => {
|
let getNext = () => {
|
||||||
|
const mailing_timeout = 5 * 1000;
|
||||||
if (!mailer.transport.isIdle()) {
|
if (!mailer.transport.isIdle()) {
|
||||||
// only retrieve new messages if there are free slots in the mailer queue
|
// only retrieve new messages if there are free slots in the mailer queue
|
||||||
return;
|
return;
|
||||||
|
@ -470,11 +471,11 @@ let sendLoop = () => {
|
||||||
findUnsent((err, message) => {
|
findUnsent((err, message) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error('Mail', err.stack);
|
log.error('Mail', err.stack);
|
||||||
setTimeout(getNext, 5 * 1000);
|
setTimeout(getNext, mailing_timeout);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!message) {
|
if (!message) {
|
||||||
setTimeout(getNext, 5 * 1000);
|
setTimeout(getNext, mailing_timeout);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -483,7 +484,7 @@ let sendLoop = () => {
|
||||||
formatMessage(message, (err, mail) => {
|
formatMessage(message, (err, mail) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error('Mail', err.stack);
|
log.error('Mail', err.stack);
|
||||||
setTimeout(getNext, 5 * 1000);
|
setTimeout(getNext, mailing_timeout);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,20 +45,21 @@ module.exports = callback => {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
let checkLoop = () => {
|
let checkLoop = () => {
|
||||||
|
const timezone_timeout = 60 * 60 * 1000;
|
||||||
let curUtcDate = new Date().toISOString().split('T').shift();
|
let curUtcDate = new Date().toISOString().split('T').shift();
|
||||||
if (curUtcDate !== lastCheck) {
|
if (curUtcDate !== lastCheck) {
|
||||||
updateTimezoneOffsets(err => {
|
updateTimezoneOffsets(err => {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error('UTC', err);
|
log.error('UTC', err);
|
||||||
}
|
}
|
||||||
setTimeout(checkLoop, 60 * 60 * 1000);
|
setTimeout(checkLoop, timezone_timeout);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
setTimeout(checkLoop, 60 * 60 * 1000);
|
setTimeout(checkLoop, timezone_timeout);
|
||||||
}
|
}
|
||||||
lastCheck = curUtcDate;
|
lastCheck = curUtcDate;
|
||||||
};
|
};
|
||||||
setTimeout(checkLoop, 60 * 60 * 1000);
|
setTimeout(checkLoop, timezone_timeout);
|
||||||
callback(null, true);
|
callback(null, true);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue