server/sports/sports-parsing.js
// Clears all old data and then fresh parses the data for each sport. 
Clears all old data and then fresh parses the data for each sport.
Clears all old data and then fresh parses the data for each sport .
function parseAllSportsData(callback) {
    console.log('Sports data parse started.');
    var counter = 0; 
    helper.deleteAllScheduledSportsGames(function () {
        helper.deleteAllSportsGameResults(function () {
            sportsData.forEach(function (sportDict) {
                var url = baseURL + sportDict.urlNumber + urlEnding;
                getScheduledGamesAndResultFromURL(url, function (error, scheduledGames, gameResults) {
                    if (!error) {
                        for (var i = 0; i < scheduledGames.length; i++) {
                            var scheduledGame = scheduledGames[i];
                            helper.createScheduledSportsGame(sportDict.sport, scheduledGame.date, scheduledGame.opponent_name, scheduledGame.location_name, function () {});
                        }
                        for (var i = 0; i < gameResults.length; i++) {
                            var gameResult = gameResults[i];
                            helper.createSportsGameResult(sportDict.sport, gameResult.date, gameResult.opponent_name, gameResult.opponent_score, gameResult.home_score, function () {});
                        }
                    } else {
                        console.log(error);
                    }
                    if (counter >= sportsData.length - 1) {
                        console.log('Sports data parse completed.');
                        callback();
                    }
                    counter++;
                });
            });
        });
    });
}
function parseAllSportsData ( callback ) { console . log ( 'Sports data parse started.' ) ; var counter = 0 ; helper . deleteAllScheduledSportsGames ( function ( ) { helper . deleteAllSportsGameResults ( function ( ) { sportsData . forEach ( function ( sportDict ) { var url = baseURL + sportDict . urlNumber + urlEnding ; getScheduledGamesAndResultFromURL ( url , function ( error , scheduledGames , gameResults ) { if ( ! error ) { for ( var i = 0 ; i < scheduledGames . length ; i ++ ) { var scheduledGame = scheduledGames [ i ] ; helper . createScheduledSportsGame ( sportDict . sport , scheduledGame . date , scheduledGame . opponent_name , scheduledGame . location_name , function ( ) { } ) ; } for ( var i = 0 ; i < gameResults . length ; i ++ ) { var gameResult = gameResults [ i ] ; helper . createSportsGameResult ( sportDict . sport , gameResult . date , gameResult . opponent_name , gameResult . opponent_score , gameResult . home_score , function ( ) { } ) ; } } else { console . log ( error ) ; } if ( counter >= sportsData . length - 1 ) { console . log ( 'Sports data parse completed.' ) ; callback ( ) ; } counter ++ ; } ) ; } ) ; } ) ; } ) ; }
Clears all old data and then fresh parses the data for each sport.
Clears all old data and then fresh parses the data for each sport .
//one bc increment after if statement