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
1 changed files with 4 additions and 3 deletions
|
@ -330,18 +330,19 @@ angular.module('ffffng')
|
|||
var allowNull = mailNumber === 1 ? ' OR last_status_mail_type IS NULL' : '';
|
||||
|
||||
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(
|
||||
'SELECT * FROM node_state ' +
|
||||
'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 ?',
|
||||
[
|
||||
startTime.unix(),
|
||||
'OFFLINE',
|
||||
previousType,
|
||||
lastSeenBefore.unix(),
|
||||
scheduleTimeBefore.unix(),
|
||||
scheduleTimeBefore.unix(),
|
||||
|
||||
MONITORING_MAILS_DB_BATCH_SIZE
|
||||
],
|
||||
|
|
Loading…
Reference in a new issue