random-parts/Team-Sports-RSVP

Question: Does it handle the case of multiple games on the same day, or games that are less than a week apart?

Haliboot opened this issue · 2 comments

Will it send email for all relevant games, or will the soonest game "hide" the other games? I haven't tested this, but it seemed like a case that could easily be overlooked, so I thought I'd ask.

It will send an email for each game in the next/upcoming day a game is scheduled for. That would be a problem for games scheduled less than two days apart as they would not get an email at all. The first game would block it.

/**
* ---
* Finds the next/upcoming gameday and places all games
* scheduled for that day into an array by the games column position
*
* | return array | value kind
* |---|---
* | `gameday_games[0][i]` | Array of gameday games column positions
* | `gameday_games[1][i]` | Array of Date Object for gameday games
*
*
* @memberof! scheduleService#
* @return {Array} column position and datetime of the next gameday games
*/
function getNextGameDayCols () {
var c_dates = schedule().compositeDates();
var today = utils(ss).date.asDayOfYear(new Date());
var game_dates = [];
var game_columns = [];
// Compares current column with next column for multiple games in one day
for (var i = 0; i < c_dates.length; i++) {
var current_date = utils(ss).date.asDayOfYear(new Date(c_dates[i]));
if (typeof c_dates[i + 1] != "undefined") {
var next_date = utils(ss).date.asDayOfYear(new Date(c_dates[i + 1]));
} else {
var next_date = false;
}
if (current_date >= today && c_dates[i] != "") {
game_dates.push(c_dates[i]);
game_columns.push(schedule(ss).gameColumn(c_dates[i]));
// Exit if the next gameday was found and there are no more games on that day
if (current_date != next_date) { break }
}
}
return [game_columns, game_dates];
}

What do you think about a change to have the emailer send emails to any game that is 3 days out [and/or 1, 2 days (this will be adjustable once a settings UI is in place)] , instead of just finding the next game day. Would probably simplify the task as well.