Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge wait time fixes from preview to prod #260

Merged
merged 3 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 21 additions & 5 deletions server/controllers/waittimes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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(
"<!channel> 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(
"<!channel> 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 {
Expand Down