Revisions
-
teeler revised this gist
May 9, 2012 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -26,7 +26,8 @@ exports.listLogs = function(req, res) { surfSessionsThisYear++; } // frothy var l = log[i].location.name; surfSeshByLoc[l] = (surfSeshByLoc[l] || 0) + 1 } res.render('list_sessions.html', { title: 'Latest Surf Sessions', -
teeler revised this gist
May 9, 2012 . 1 changed file with 3 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,13 +25,8 @@ exports.listLogs = function(req, res) { if(y === currentYear) { surfSessionsThisYear++; } // frothy surfSeshByLoc[i] = (surfSeshByLoc[i] || 0) + 1 } res.render('list_sessions.html', { title: 'Latest Surf Sessions', @@ -45,4 +40,4 @@ exports.listLogs = function(req, res) { }); }); }); }; -
kconragan created this gist
May 9, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,48 @@ exports.listLogs = function(req, res) { SurfSession.find() .populate('location') .run(function(err, log) { Wave.find(function(err, waves) { var surfHeight = SurfSession.schema.path('surfHeight').enumValues; var surfConditions = SurfSession.schema.path('surfConditions').enumValues; var surfStoke = new SurfSession().generateStoke(); var currentYear = moment().year(); var surfSessionsThisYear = 0; var surfSeshByLoc = {}; waves.forEach(function(w) { var wave = { "name": w.name, "count": 0 }; surfSeshByLoc[w.name] = 0; }); // find number of sessions for current year // and build map of sessions by wave for(var i = 0; i < log.length; i++) { var y = moment(log[i].timestamp).year(); if(y === currentYear) { surfSessionsThisYear++; } for(var key in surfSeshByLoc) { if(surfSeshByLoc.hasOwnProperty(key)) { if(key === log[i].location.name) { surfSeshByLoc[key] = surfSeshByLoc[key] + 1; } } } } res.render('list_sessions.html', { title: 'Latest Surf Sessions', log: log, waves: waves, surfSessionsThisYear: surfSessionsThisYear, allSurfSessions: log.length, surfHeight: surfHeight, surfConditions: surfConditions, surfStoke: surfStoke }); }); }); };