Fix: Don't send monitoring mails too soon after each other.
Fixes: https://github.com/freifunkhamburg/ffffng/issues/17
This commit is contained in:
parent
7b2e0efcab
commit
9c7b2558f0
|
@ -330,18 +330,19 @@ angular.module('ffffng')
|
||||||
var allowNull = mailNumber === 1 ? ' OR last_status_mail_type IS NULL' : '';
|
var allowNull = mailNumber === 1 ? ' OR last_status_mail_type IS NULL' : '';
|
||||||
|
|
||||||
var schedule = MONITORING_OFFLINE_MAILS_SCHEDULE[mailNumber];
|
var schedule = MONITORING_OFFLINE_MAILS_SCHEDULE[mailNumber];
|
||||||
var lastSeenBefore = moment().subtract(schedule.amount, schedule.unit);
|
var scheduleTimeBefore = moment().subtract(schedule.amount, schedule.unit);
|
||||||
|
|
||||||
Database.all(
|
Database.all(
|
||||||
'SELECT * FROM node_state ' +
|
'SELECT * FROM node_state ' +
|
||||||
'WHERE modified_at < ? AND state = ? AND (last_status_mail_type = ?' + allowNull + ') AND ' +
|
'WHERE modified_at < ? AND state = ? AND (last_status_mail_type = ?' + allowNull + ') AND ' +
|
||||||
'last_seen < ? ' +
|
'last_seen <= ? AND last_status_mail_send <= ? ' +
|
||||||
'ORDER BY id ASC LIMIT ?',
|
'ORDER BY id ASC LIMIT ?',
|
||||||
[
|
[
|
||||||
startTime.unix(),
|
startTime.unix(),
|
||||||
'OFFLINE',
|
'OFFLINE',
|
||||||
previousType,
|
previousType,
|
||||||
lastSeenBefore.unix(),
|
scheduleTimeBefore.unix(),
|
||||||
|
scheduleTimeBefore.unix(),
|
||||||
|
|
||||||
MONITORING_MAILS_DB_BATCH_SIZE
|
MONITORING_MAILS_DB_BATCH_SIZE
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in a new issue