diff --git a/README.md b/README.md index 868ad6e..a535f20 100644 --- a/README.md +++ b/README.md @@ -158,10 +158,8 @@ Create a `.env` file in the `client` folder with the following fields: Add them to the `.env` file like so: ``` -{ - name=value, - name=value, -} +name=value +name=value ``` ### Server-Side diff --git a/server/controllers/waittimes.js b/server/controllers/waittimes.js index ef0b1f1..ed03c68 100644 --- a/server/controllers/waittimes.js +++ b/server/controllers/waittimes.js @@ -8,6 +8,9 @@ let last_pinged = null; const ping_threshold_mins = 30; const ping_interval_mins = 15; +let minute_ago_waittime = null; +let minute_ago_time = null; + const models = require("../models"); const { Sequelize } = require("../models"); const moment = require("moment-timezone"); @@ -74,11 +77,24 @@ exports.wait_time_data = function () { const waitTime = numUnhelped * minsPerStudent / numTAs; - if (waitTime > ping_threshold_mins && (last_pinged == null || now.diff(last_pinged, "seconds") >= ping_interval_mins * 60)) { - slack.send_message( - " The wait time is " + (Math.round(100 * waitTime) / 100) + " minutes right now. More TAs might be needed. (<" + config.PROTOCOL + "://" + config.DOMAIN + "/|view»>)" - ); - last_pinged = now; + if (minute_ago_time == null) { + minute_ago_time = now; + minute_ago_waittime = waitTime; + } + else { + if (last_pinged == null || now.diff(last_pinged, "seconds") >= ping_interval_mins * 60) { + if (waitTime > ping_threshold_mins && minute_ago_waittime > ping_threshold_mins) { + slack.send_message( + " The wait time is " + (Math.round(waitTime)) + " minutes right now. More TAs might be needed. (<" + config.PROTOCOL + "://" + config.DOMAIN + "/|view»>)" + ); + last_pinged = now; + } + } + + if (now.diff(minute_ago_time, "minutes") >= 1) { + minute_ago_time = now; + minute_ago_waittime = waitTime; + } } return {