diff --git a/.gitignore b/.gitignore
index 821f3ff..9adba76 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,3 +12,6 @@ node_modules
# Config File
leagues.json
+
+# Data Output
+Seasons/
diff --git a/helpers/fetch_games.js b/helpers/fetch_games.js
index 455194c..cf4e254 100644
--- a/helpers/fetch_games.js
+++ b/helpers/fetch_games.js
@@ -24,7 +24,7 @@ function fetchGames(db, opts, callback){
console.log('Requesting main scoreboard page...');
processWebpage(
- 'http://games.espn.go.com/ffl/scoreboard?leagueId=' + opts.leagueObj.leagueId + '&matchupPeriodId=' + opts.week,
+ 'http://games.espn.com/ffl/scoreboard?leagueId=' + opts.leagueObj.leagueId + '&matchupPeriodId=' + opts.week,
parseHTML,
(opts.leagueObj.dbName + '/week' + opts.week + '_' + timestamp + '.png')
);
@@ -109,7 +109,7 @@ function fetchGames(db, opts, callback){
console.log('Requesting game ' + gameNumber +' detail page...');
processWebpage(
- 'http://games.espn.go.com' + boxScorePath,
+ 'http://games.espn.com' + boxScorePath,
function(detailHTML){
var $ = cheerio.load(detailHTML);
var $teamDetails = $('.games-fullcol').find('.playerTableTable');
diff --git a/helpers/fetch_players.js b/helpers/fetch_players.js
index 3000f3e..e1668f2 100644
--- a/helpers/fetch_players.js
+++ b/helpers/fetch_players.js
@@ -15,7 +15,7 @@ function fetchPlayers(db, opts, callback){
// Set up some variables
var Collection = db.collection(collectionName);
- var baseUrl = 'http://games.espn.go.com';
+ var baseUrl = 'http://games.espn.com';
var teamCount = 0;
var playersPerTeam = 0;
var projectionsSaved = 0;
diff --git a/stats_node.js b/stats_node.js
index 96e70f7..35b2a7e 100644
--- a/stats_node.js
+++ b/stats_node.js
@@ -57,20 +57,24 @@ var runPlayerStats = argv.players;
var verbose = argv.verbose;
// Before we get going, connect to Mongo
-MongoClient.connect('mongodb://' + mongoUrl + ':' + mongoPort +'/'+ leagueObj.dbName, function(err, db) {
+var mongodb = 'mongodb://' + mongoUrl + ':' + mongoPort +'/'+ leagueObj.dbName;
+//console.log(mongodb);
+
+MongoClient.connect(mongodb, function(err, db) {
if(err) throw err;
// Output header
+ console.log('
Interstate Football Freaks ' + (new Date()).getFullYear() + '
');
+ // console.log('');
+ console.log('
');
console.log('');
+ console.log('Home');
console.log('');
- console.log('=========================');
if(week === 'all'){
- console.log(' Year-to-date statistics');
+ console.log('Year-To-Date Statistics
');
} else {
- console.log(' Week ' + week + ' statistics');
+ console.log('Week ' + week + ' Statistics
');
}
- console.log('=========================');
- console.log('');
console.log('');
// Start doing some calculations
@@ -112,25 +116,26 @@ var calculateTeamsVsProjections = function(db, callback){
var teamsVsProjections = Games.aggregate(teamsVsProjectionsAggregate);
if(verbose){
- console.log('Teams vs. projections');
- console.log('=========================');
- console.log('');
+ console.log('');
+ console.log('
Teams vs. Projections
');
}
teamsVsProjections.each(function(err, doc){
if(!err && doc && verbose) {
var statStr = '';
- console.log(doc.team + ', Week ' + doc.week);
- console.log('------------');
- statStr += 'Projected: ' + doc.projected + '; Actual: ' + doc.actual + '; ';
+ console.log('
')
+ console.log('
' + doc.team + ', Week ' + doc.week + '
');
+ statStr += 'Projected: ' + doc.projected + '
Actual: ' + doc.actual + '
';
if(doc.adjusted !== doc.actual) {
- statStr += 'Adjusted: ' + doc.adjusted + '; ';
+ statStr += 'Adjusted: ' + doc.adjusted + '
';
}
- statStr += 'Diff: ' + (doc.diff > 0 ? '+' : '') + doc.diff.toFixed(2);
+ statStr += 'Diff: ' + (doc.diff > 0 ? '+' : '') + doc.diff.toFixed(2);
console.log(statStr);
- console.log('');
+ console.log('
');
+ console.log('');
}
});
+
var avgScoreAggregate = [
{$match: {'_id.w' : week}},
{$unwind: '$scores'},
@@ -156,14 +161,13 @@ var calculateTeamsVsProjections = function(db, callback){
var avgScore = Games.aggregate(avgScoreAggregate);
-
avgScore.each(function(err, doc){
if(!err && doc) {
- console.log('');
- console.log('Average score vs. projection');
- console.log('=========================');
- console.log('');
- console.log((doc.averageDiff > 0 ? '+' : '') + doc.averageDiff.toFixed(2));
+ console.log('
');
+
+ console.log('');
+ console.log('
Average Score vs. Projection
');
+ console.log('' + (doc.averageDiff > 0 ? '+' : '') + doc.averageDiff.toFixed(2) + '
');
} else if(!doc) {
if(callback){
callback(db);
@@ -177,22 +181,22 @@ var calculateTeamsVsProjections = function(db, callback){
var calculateGameResults = function(db, callback){
var Games = db.collection(gamesCollectionName);
- console.log('');
- console.log('');
- console.log('How often was the outcome of the game correctly projected?');
- console.log('==========================================================');
+ console.log('');
+ console.log('');
+ console.log('
How often was the outcome of the game correctly projected?
');
var correctGames = Games.aggregate(outcomeAggregate);
correctGames.each(function(err, doc){
if(!err && doc && verbose) {
- console.log('');
- console.log(doc.matchup);
- console.log('--------------------');
- console.log('Projected Winner : ' + doc.projectedWinner);
- console.log('Actual Winner : ' + doc.actualWinner);
- console.log('Actual Winner with Spread : ' + doc.actualWinnerWithSpread);
- console.log('Projection was ' + doc.wasProjectionCorrect);
+ console.log('
');
+ console.log('
' + doc.matchup + '
');
+ console.log('Projected Winner: ' + doc.projectedWinner + '
');
+ console.log('Actual Winner: ' + doc.actualWinner + '
');
+ console.log('Actual Winner with Spread: ' + doc.actualWinnerWithSpread + '
');
+ console.log('Projection was ' + doc.wasProjectionCorrect + '');
+ console.log('
')
+ console.log('');
} else if(!doc) {
if(callback){
callback(db);
@@ -238,8 +242,8 @@ var calculateProjectionPercentage = function(db, callback){
percentage.each(function(err, doc){
if(!err && doc) {
- console.log('Projections were correct ' + doc.percentageCorrect.toFixed(2) + '% of the time.');
- console.log('');
+ console.log('
Projections were correct ' + doc.percentageCorrect.toFixed(2) + '% of the time.');
+ console.log('
');
} else if(!doc) {
if(callback){
callback(db);
@@ -279,20 +283,26 @@ var calculatePlayerStats = function(db, callback){
results.each(function(err, doc){
if(!err && doc) {
if(counter === 0){
- console.log('');
- console.log('');
+ //console.log('');
+ //console.log('');
+ console.log('');
console.log('Player Performances vs Projections per ' + title);
- console.log('===========================================');
- console.log('');
+ //console.log('===========================================');
+ console.log('
');
}
- console.log(doc._id + ' : ' + (doc.avgDiff > 0 ? '+' : '') + doc.avgDiff.toFixed(2));
+ console.log('')
+ console.log('' + doc._id + ': ' + (doc.avgDiff > 0 ? '+' : '') + doc.avgDiff.toFixed(2) +'
');
if(verbose){
- console.log('--------');
- console.log('Max Score : '+ doc.maxScore +' | Min Score : '+ doc.minScore +' | Sample Size : '+ doc.count );
- console.log('');
+ //console.log('--------');
+ console.log('Max Score: '+ doc.maxScore +'
');
+ console.log('Min Score: '+ doc.minScore +'
');
+ console.log('Sample Size: '+ doc.count );
+ console.log('
');
+ //console.log('');
}
+ console.log('');
counter++;
} else if(!doc && isLast) {