server/sports/sports-parsing.js
// Sends one notification about every game scheduled the current day.
Sends one notification about every game scheduled the current day.
Sends one notification about every game scheduled the current day .
function sendScheduledGameNotifications() {
    parseAllSportsData(function () {
        helper.findAllScheduledGames(function (scheduledGames) {
            if (scheduledGames) {
                var counter = 0;
                var sportsOfScheduledGamesToday = [];
                scheduledGames.forEach(function (scheduledGame) {
                    var gameDate = moment(scheduledGame.game_date, 'yyyy.MM.ddTHH:mm:ss.SSSZ');
                    if (!sportsOfScheduledGamesToday.includes(scheduledGame.sport_name) && gameDate.isSame(moment(), 'd')) {
                        sportsOfScheduledGamesToday.push(scheduledGame.sport_name);
                    }
                    if (counter >= scheduledGames.length - 1) {
                        var notificationText = 'Sports events today: ' + sportsOfScheduledGamesToday.join(', ') + '.'; 
                        if (sportsOfScheduledGamesToday.length == 0) {
                            notificationText = 'There are no sports events today.'
                        }
                        helper.findAllClients(function (clients) {
                            if (clients) {
                                clients.forEach(function (client) {
                                    if (client.push_token) {
                                        notifications.sendNotification([client.push_token], notificationText, true);
                                    }
                                });
                            }
                        });
                    }
                    counter++;
                });
            }
        });
    });
}
function sendScheduledGameNotifications ( ) { parseAllSportsData ( function ( ) { helper . findAllScheduledGames ( function ( scheduledGames ) { if ( scheduledGames ) { var counter = 0 ; var sportsOfScheduledGamesToday = [ ] ; scheduledGames . forEach ( function ( scheduledGame ) { var gameDate = moment ( scheduledGame . game_date , 'yyyy.MM.ddTHH:mm:ss.SSSZ' ) ; if ( ! sportsOfScheduledGamesToday . includes ( scheduledGame . sport_name ) && gameDate . isSame ( moment ( ) , 'd' ) ) { sportsOfScheduledGamesToday . push ( scheduledGame . sport_name ) ; } if ( counter >= scheduledGames . length - 1 ) { var notificationText = 'Sports events today: ' + sportsOfScheduledGamesToday . join ( ', ' ) + '.' ; if ( sportsOfScheduledGamesToday . length == 0 ) { notificationText = 'There are no sports events today.' } helper . findAllClients ( function ( clients ) { if ( clients ) { clients . forEach ( function ( client ) { if ( client . push_token ) { notifications . sendNotification ( [ client . push_token ] , notificationText , true ) ; } } ) ; } } ) ; } counter ++ ; } ) ; } } ) ; } ) ; }
Sends one notification about every game scheduled the current day.
Sends one notification about every game scheduled the current day .