diff --git a/app.js b/app.js index e45521e..300d12d 100644 --- a/app.js +++ b/app.js @@ -20,6 +20,7 @@ var app = express(); app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'hbs'); +// lol, could probably get rid of this or get a favicon :P // uncomment after placing your favicon in /public //app.use(favicon(path.join(__dirname, 'public', 'favicon.ico'))); app.use(logger('dev')); @@ -50,6 +51,7 @@ app.get('/verify', index.GETemailver); app.get('/user', function(req, res, next) { res.json({user: req.user}); }) +// I might add a few organizational comments and line breaks here app.post('/api/login', index.POSTlogin); app.post('/api/logout', index.POSTlogout); app.post('/api/register', index.POSTregister); @@ -72,6 +74,11 @@ app.delete('/api/delUser/:_id', index.DELETEdelUser); app.post('/api/editOverview/', index.POSTeditOverview); app.get('/api/overview', index.GEToverview); +//kinda weird to do this as the end of the middleware chain. I would probably do +// app.get('/', function(req, res){ +// res.sendFile('main.html', { root: path.join(__dirname, 'views') }); +// }) +// that what it only sends the file if they go to '/' and not to any request that is unrecognized. app.use(function(req, res) { // Use res.sendfile, as it streams instead of reading the file into memory. res.sendFile('main.html', { root: path.join(__dirname, 'views') }); diff --git a/models/cohort.js b/models/cohort.js index ef909f1..6d73a71 100644 --- a/models/cohort.js +++ b/models/cohort.js @@ -1,6 +1,7 @@ var mongoose = require('mongoose'); var cohortSchema = mongoose.Schema({ + // how do you know what students are in the cohort? name: String, comment: String, actionSteps: String, diff --git a/models/overview.js b/models/overview.js index 43ebbd6..445ca15 100644 --- a/models/overview.js +++ b/models/overview.js @@ -1,5 +1,6 @@ var mongoose = require('mongoose'); +//why does overview have it's own database object? What is it an overview of? var overviewSchema = mongoose.Schema({ overview: String }); diff --git a/models/student.js b/models/student.js index 9ffdc49..0a473c5 100644 --- a/models/student.js +++ b/models/student.js @@ -2,8 +2,10 @@ var mongoose = require('mongoose'); var studentSchema = mongoose.Schema({ name: String, + // is this how you know which cohort they are in? program: String, archived: Boolean, + //should probably be a ref to overview overview: String, actionSteps: String }); diff --git a/public/javascripts/cohortController.js b/public/javascripts/cohortController.js index 80a5fc0..0515867 100644 --- a/public/javascripts/cohortController.js +++ b/public/javascripts/cohortController.js @@ -7,6 +7,7 @@ var cohortController = function($scope, $http, $state) { var cohortStudentsController = function($scope, $http, $state) { $scope.showStudent = function(student) { + // seems a bit convoluted but it works $scope.$parent.$parent.currentStudent = student; $scope.$parent.$parent.editStudent = angular.copy(student); $state.go('index.student.showData'); diff --git a/public/javascripts/cohortVizController.js b/public/javascripts/cohortVizController.js index b03e2ef..e200a3c 100644 --- a/public/javascripts/cohortVizController.js +++ b/public/javascripts/cohortVizController.js @@ -4,6 +4,9 @@ var cohortVizController = function($scope, $http, $state) { $http.get('/api/cohort/data/' + $scope.currentCohortName).then(function successCallback( response) { $scope.timeFrame = "-1"; + // oh man, this is a bit late, but there are some really cool ways to do shit like this in es6/7/8, if you are interested look into object destructuring and spread + // it would be $scope = {...$scope, ...response.data}; + // or Object.assign($scope, response.data); $scope.attendance = response.data.attendanceList; $scope.dates = response.data.datesList; $scope.stars = response.data.starsList; @@ -18,6 +21,7 @@ var cohortVizController = function($scope, $http, $state) { var thresh = new Date(); thresh.setDate(thresh.getDate() - days); if (arr !== undefined) { + // this would have been a great place for a dates.filter() for (var i = 0; i < arr.length; i++) { if (new Date(dates[i]) >= thresh || days === -1) { newArray.push(arr[i]); @@ -30,13 +34,21 @@ var cohortVizController = function($scope, $http, $state) { var formatPieData = function(data){ var newList = []; + // no dicts in JS, objects have some important differences var dataDict = {}; + // probably not the clearest way to format this if (data !== undefined) { data.forEach(function(i) { if (i !== undefined && i === i && i!== null) { dataDict[i] = (dataDict[i] || 0) + 1; } }); + // would have probably gone with + // return Object.keys.map(function (key){ + // return {key:key, y:dataDict[key]} + //}) + //or with new syntax + // return Object.keys,map(key => ({key, y:dataDict[key]})) var keys = Object.keys(dataDict); for (var i = 0; i < keys.length; i++) { newList.push({ diff --git a/public/javascripts/indexController.js b/public/javascripts/indexController.js index 5f29d67..c5f31fc 100644 --- a/public/javascripts/indexController.js +++ b/public/javascripts/indexController.js @@ -16,6 +16,7 @@ var indexController = function($scope, $http, $location, $state) { }); $scope.logout = function(){ + // if you guys are curious you should look in the the official promise spec, which is different and in my opinion way cleaner than the q bullshit that angular uses $http.post("/api/logout").then(function successCallback(response) { $state.go('login'); }, function errorCallback(response) { diff --git a/routes/entryRoutes.js b/routes/entryRoutes.js index e8cd47f..3533d77 100644 --- a/routes/entryRoutes.js +++ b/routes/entryRoutes.js @@ -23,6 +23,7 @@ routes.POSTnewDailyEntry = function(req, res, next) { var engageContent = parseInt(req.body.engageContent); var engagePeer = parseInt(req.body.engagePeer); var engageAdult = parseInt(req.body.engageAdult); + //oooof ^ looks like it was a pain to write var querry = { _studentID: studentID, date: currentDate, @@ -38,6 +39,7 @@ routes.POSTnewDailyEntry = function(req, res, next) { engagePeer: engagePeer, engageAdult:engageAdult }; + // why define the callback here instead of in line? Not bad just curious var callback = function(err, newEntryObj) { if (err) return res.status(500).json({msg: 'Error submitting entry'}); res.json({newEntryObj:newEntryObj, msg: 'Entry submitted successfully!'});