From 9c7b2558f0e2dbf9ea0a314e5899b0277bcfbf43 Mon Sep 17 00:00:00 2001 From: baldo Date: Sat, 25 Jun 2016 14:18:43 +0200 Subject: [PATCH] Fix: Don't send monitoring mails too soon after each other. Fixes: https://github.com/freifunkhamburg/ffffng/issues/17 --- server/services/monitoringService.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server/services/monitoringService.js b/server/services/monitoringService.js index f27ec2d..cfdd5e0 100644 --- a/server/services/monitoringService.js +++ b/server/services/monitoringService.js @@ -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 ],