From 06fe5390baf037fb7f08ae540ff483d25db9d04c Mon Sep 17 00:00:00 2001 From: Michael Q Larson Date: Mon, 24 Nov 2014 18:07:03 -0800 Subject: [PATCH] seems to attempt to write timestamp --- app.js | 3 +- controllers/challenges.js | 2 +- models/User.js | 1 + views/account/profile.jade | 4 + views/partials/challenges.jade | 248 ++++++++++++++++----------------- views/partials/navbar.jade | 2 +- 6 files changed, 133 insertions(+), 127 deletions(-) diff --git a/app.js b/app.js index 02bbb774fb..2f027fb525 100644 --- a/app.js +++ b/app.js @@ -163,8 +163,9 @@ app.get('/account/unlink/:provider', userController.getOauthUnlink); * API examples routes. */ app.post('/completed_challenge', function(req, res) { - req.user.challengesCompleted.push(parseInt(req.body.cn)); + req.user.challengesHash[req.body.cn] = Math.round(+new Date()/1000); req.user.save(); + console.log(req.user.challengesHash); }); /** diff --git a/controllers/challenges.js b/controllers/challenges.js index 71b86c1bd1..e7f951f0cc 100644 --- a/controllers/challenges.js +++ b/controllers/challenges.js @@ -19,7 +19,7 @@ exports.returnChallenge = function(req, res, next) { video: c.video, time: c.time, steps: c.steps, - cc: req.user.challengesCompleted + cc: req.user.challengesHash }); }); }; \ No newline at end of file diff --git a/models/User.js b/models/User.js index d4a265ccc7..5bc9f8553e 100644 --- a/models/User.js +++ b/models/User.js @@ -14,6 +14,7 @@ var userSchema = new mongoose.Schema({ instagram: String, tokens: Array, challengesCompleted: { type: Array, default: [] }, + challengesHash: { type: Object, default: {} }, profile: { name: { type: String, default: '' }, diff --git a/views/account/profile.jade b/views/account/profile.jade index a7b443c7a0..69ef916bce 100644 --- a/views/account/profile.jade +++ b/views/account/profile.jade @@ -29,6 +29,10 @@ block content span.ion-edit | Update my profile + h1 Completed Challenges + ul + //each val, index in user.challengesHash + //li= index + ': ' + val h3 Danger Zone button.btn.btn-danger.confirm-deletion span.ion-trash-b diff --git a/views/partials/challenges.jade b/views/partials/challenges.jade index 7f3cd3d740..78ff771a06 100644 --- a/views/partials/challenges.jade +++ b/views/partials/challenges.jade @@ -3,128 +3,128 @@ .panel-body ol(start='0') li - a(href="/challenges/0", class="#{ cc.indexOf(0) > -1 ? 'strikethrough' : '' }") A One-minute Introduction to Free Code Camp + a(href="/challenges/0", class="#{ cc.hasOwnProperty('0') ? 'strikethrough' : '' }") A One-minute Introduction to Free Code Camp |   (1 min) - li - a(href="/challenges/1", class="#{ cc.indexOf(1) > -1 ? 'strikethrough' : '' }") Enter the Free Code Camp Chat Room - |   (5 mins) - li - a(href="/challenges/2", class="#{ cc.indexOf(2) > -1 ? 'strikethrough' : '' }") Create a Website and Deploy it to the Internet - |   (5 mins) - li - a(href="/challenges/3", class="#{ cc.indexOf(3) > -1 ? 'strikethrough' : '' }") Install Github's Atom Text Editor - |   (5 mins) - li - a(href="/challenges/4", class="#{ cc.indexOf(4) > -1 ? 'strikethrough' : '' }") Modify and Redeploy Your Website - |   (5 mins) - li - a(href="/challenges/5", class="#{ cc.indexOf(6) > -1 ? 'strikethrough' : '' }") Add Dynamic Content to your Website - |   (10 mins) - li - a(href="/challenges/6", class="#{ cc.indexOf(7) > -1 ? 'strikethrough' : '' }") Codecademy's HTML & CSS track - |   (7 hrs) - li - a(href="/challenges/7", class="#{ cc.indexOf(8) > -1 ? 'strikethrough' : '' }") Experiment with HTML and CSS in CodePen - |   (10 mins) - li - a(href="/challenges/8", class="#{ cc.indexOf(9) > -1 ? 'strikethrough' : '' }") Code School's Try jQuery - |   (4 hrs) - li - a(href="/challenges/9", class="#{ cc.indexOf(10) > -1 ? 'strikethrough' : '' }") jQuery Exercises - |   (3 hrs) - li - a(href="/challenges/10", class="#{ cc.indexOf(11) > -1 ? 'strikethrough' : '' }") Code School's Discover DevTools - |   (2 hrs) - li - a(href="/challenges/11", class="#{ cc.indexOf(12) > -1 ? 'strikethrough' : '' }") Customize Bootstrap with Bootswatch - |   (10 mins) - li - a(href="/challenges/12", class="#{ cc.indexOf(13) > -1 ? 'strikethrough' : '' }") Inject Life with CSS Transformations - |   (15 mins) - li - a(href="/challenges/13", class="#{ cc.indexOf(14) > -1 ? 'strikethrough' : '' }") Codecademy's JavaScript track - |   (10 hrs) - li - a(href="/challenges/14", class="#{ cc.indexOf(16) > -1 ? 'strikethrough' : '' }") Stanford's Introduction to Computer Science - |   (24 hrs) - li - a(href="/challenges/15", class="#{ cc.indexOf(15) > -1 ? 'strikethrough' : '' }") Get Help The Hacker Way with RSAP - |   (30 mins) - li - a(href="/challenges/16", class="#{ cc.indexOf(17) > -1 ? 'strikethrough' : '' }") Learn Regular Expressions - |   (1 hr) - li - a(href="/challenges/17", class="#{ cc.indexOf(5) > -1 ? 'strikethrough' : '' }") Start Your First Pair Programming Session - |   (30 mins | Pair) - li - a(href="/challenges/18", class="#{ cc.indexOf(17) > -1 ? 'strikethrough' : '' }") Easy Algorithm Scripting Challenges on Coderbyte - |   (15 hrs | Pair) - li - a(href="/challenges/19", class="#{ cc.indexOf(18) > -1 ? 'strikethrough' : '' }") Stanford's Relational Databases Mini-course - |   (1 hr) - li - a(href="/challenges/20", class="#{ cc.indexOf(19) > -1 ? 'strikethrough' : '' }") Stanford's SQL Mini-course - |   (4 hrs | Pair) - li - a(href="/challenges/21", class="#{ cc.indexOf(20) > -1 ? 'strikethrough' : '' }") Stanford's JSON Mini-course - |   (1 hrs | Pair) - li - a(href="/challenges/22", class="#{ cc.indexOf(21) > -1 ? 'strikethrough' : '' }") Medium Algorithm Scripting Challenges on Coderbyte - |   (15 hrs | Pair) - li - a.disabled(href="/challenges/23", class="#{ cc.indexOf(22) > -1 ? 'strikethrough' : '' }") Build an Interview Question Machine - |   (5 hrs | Pair) - li - a.disabled(href="/challenges/24", class="#{ cc.indexOf(23) > -1 ? 'strikethrough' : '' }") Build a Text-based Adventure - |   (5 hrs | Pair) - li - a.disabled(href="/challenges/25", class="#{ cc.indexOf(24) > -1 ? 'strikethrough' : '' }") Hard Algorithm Scripting Challenges on Coderbyte - |   (15 hrs | Pair) - li - a.disabled(href="/challenges/26", class="#{ cc.indexOf(25) > -1 ? 'strikethrough' : '' }") Code School's Try Git - |   (30 mins) - li - a.disabled(href="/challenges/27", class="#{ cc.indexOf(26) > -1 ? 'strikethrough' : '' }") Install Node.js - |   (1 hr) - li - a.disabled(href="/challenges/28", class="#{ cc.indexOf(27) > -1 ? 'strikethrough' : '' }") Clone a Github Repo - |   (15 mins) - li - a.disabled(href="/challenges/29", class="#{ cc.indexOf(28) > -1 ? 'strikethrough' : '' }") Deploy an app to Heroku - |   (15 mins) - li - a.disabled(href="/challenges/30", class="#{ cc.indexOf(29) > -1 ? 'strikethrough' : '' }") Code School's Real-time web with Node.JS - |   (5 hrs) - li - a.disabled(href="/challenges/31", class="#{ cc.indexOf(30) > -1 ? 'strikethrough' : '' }") Try MongoDB - |   (30 mins) - li - a.disabled(href="/challenges/32", class="#{ cc.indexOf(31) > -1 ? 'strikethrough' : '' }") Explore your Network with the LinkedIn API - |   (1 hr) - li - a.disabled(href="/challenges/33", class="#{ cc.indexOf(32) > -1 ? 'strikethrough' : '' }") Build your first API - |   (10 hrs | Pair) - li - a.disabled(href="/challenges/34", class="#{ cc.indexOf(33) > -1 ? 'strikethrough' : '' }") Aggregate Data with Chron Jobs and Screen Scraping - |   (10 hrs | Pair) - li - a.disabled(href="/challenges/35", class="#{ cc.indexOf(34) > -1 ? 'strikethrough' : '' }") Code School's Shaping up with Angular.JS - |   (5 hrs) - li - a.disabled(href="/challenges/36", class="#{ cc.indexOf(35) > -1 ? 'strikethrough' : '' }") Reverse Engineer SnapChat - |   (50 hrs | Pair) - li - a.disabled(href="/challenges/37", class="#{ cc.indexOf(36) > -1 ? 'strikethrough' : '' }") Reverse Engineer Reddit - |   (50 hrs | Pair) - li - a.disabled(href="/challenges/38", class="#{ cc.indexOf(37) > -1 ? 'strikethrough' : '' }") Reverse Engineer Pintrest - |   (50 hrs | Pair) - li - a.disabled(href="/challenges/39", class="#{ cc.indexOf(38) > -1 ? 'strikethrough' : '' }") Help a Nonprofit: Team Project - |   (150 hrs | Pair) - li - a.disabled(href="/challenges/40", class="#{ cc.indexOf(39) > -1 ? 'strikethrough' : '' }") Help a Nonprofit: Solo Project - |   (150 hrs | Pair) - li - a.disabled(href="/challenges/41", class="#{ cc.indexOf(40) > -1 ? 'strikethrough' : '' }") Crack the Coding Interview - |   (5 hrs) \ No newline at end of file + //li + // a(href="/challenges/1", class="#{ cc.indexOf(1) > -1 ? 'strikethrough' : '' }") Enter the Free Code Camp Chat Room + // |   (5 mins) + //li + // a(href="/challenges/2", class="#{ cc.indexOf(2) > -1 ? 'strikethrough' : '' }") Create a Website and Deploy it to the Internet + // |   (5 mins) + //li + // a(href="/challenges/3", class="#{ cc.indexOf(3) > -1 ? 'strikethrough' : '' }") Install Github's Atom Text Editor + // |   (5 mins) + //li + // a(href="/challenges/4", class="#{ cc.indexOf(4) > -1 ? 'strikethrough' : '' }") Modify and Redeploy Your Website + // |   (5 mins) + //li + // a(href="/challenges/5", class="#{ cc.indexOf(6) > -1 ? 'strikethrough' : '' }") Add Dynamic Content to your Website + // |   (10 mins) + //li + // a(href="/challenges/6", class="#{ cc.indexOf(7) > -1 ? 'strikethrough' : '' }") Codecademy's HTML & CSS track + // |   (7 hrs) + //li + // a(href="/challenges/7", class="#{ cc.indexOf(8) > -1 ? 'strikethrough' : '' }") Experiment with HTML and CSS in CodePen + // |   (10 mins) + //li + // a(href="/challenges/8", class="#{ cc.indexOf(9) > -1 ? 'strikethrough' : '' }") Code School's Try jQuery + // |   (4 hrs) + //li + // a(href="/challenges/9", class="#{ cc.indexOf(10) > -1 ? 'strikethrough' : '' }") jQuery Exercises + // |   (3 hrs) + //li + // a(href="/challenges/10", class="#{ cc.indexOf(11) > -1 ? 'strikethrough' : '' }") Code School's Discover DevTools + // |   (2 hrs) + //li + // a(href="/challenges/11", class="#{ cc.indexOf(12) > -1 ? 'strikethrough' : '' }") Customize Bootstrap with Bootswatch + // |   (10 mins) + //li + // a(href="/challenges/12", class="#{ cc.indexOf(13) > -1 ? 'strikethrough' : '' }") Inject Life with CSS Transformations + // |   (15 mins) + //li + // a(href="/challenges/13", class="#{ cc.indexOf(14) > -1 ? 'strikethrough' : '' }") Codecademy's JavaScript track + // |   (10 hrs) + //li + // a(href="/challenges/14", class="#{ cc.indexOf(16) > -1 ? 'strikethrough' : '' }") Stanford's Introduction to Computer Science + // |   (24 hrs) + //li + // a(href="/challenges/15", class="#{ cc.indexOf(15) > -1 ? 'strikethrough' : '' }") Get Help The Hacker Way with RSAP + // |   (30 mins) + //li + // a(href="/challenges/16", class="#{ cc.indexOf(17) > -1 ? 'strikethrough' : '' }") Learn Regular Expressions + // |   (1 hr) + //li + // a(href="/challenges/17", class="#{ cc.indexOf(5) > -1 ? 'strikethrough' : '' }") Start Your First Pair Programming Session + // |   (30 mins | Pair) + //li + // a(href="/challenges/18", class="#{ cc.indexOf(17) > -1 ? 'strikethrough' : '' }") Easy Algorithm Scripting Challenges on Coderbyte + // |   (15 hrs | Pair) + //li + // a(href="/challenges/19", class="#{ cc.indexOf(18) > -1 ? 'strikethrough' : '' }") Stanford's Relational Databases Mini-course + // |   (1 hr) + //li + // a(href="/challenges/20", class="#{ cc.indexOf(19) > -1 ? 'strikethrough' : '' }") Stanford's SQL Mini-course + // |   (4 hrs | Pair) + //li + // a(href="/challenges/21", class="#{ cc.indexOf(20) > -1 ? 'strikethrough' : '' }") Stanford's JSON Mini-course + // |   (1 hrs | Pair) + //li + // a(href="/challenges/22", class="#{ cc.indexOf(21) > -1 ? 'strikethrough' : '' }") Medium Algorithm Scripting Challenges on Coderbyte + // |   (15 hrs | Pair) + //li + // a.disabled(href="/challenges/23", class="#{ cc.indexOf(22) > -1 ? 'strikethrough' : '' }") Build an Interview Question Machine + // |   (5 hrs | Pair) + //li + // a.disabled(href="/challenges/24", class="#{ cc.indexOf(23) > -1 ? 'strikethrough' : '' }") Build a Text-based Adventure + // |   (5 hrs | Pair) + //li + // a.disabled(href="/challenges/25", class="#{ cc.indexOf(24) > -1 ? 'strikethrough' : '' }") Hard Algorithm Scripting Challenges on Coderbyte + // |   (15 hrs | Pair) + //li + // a.disabled(href="/challenges/26", class="#{ cc.indexOf(25) > -1 ? 'strikethrough' : '' }") Code School's Try Git + // |   (30 mins) + //li + // a.disabled(href="/challenges/27", class="#{ cc.indexOf(26) > -1 ? 'strikethrough' : '' }") Install Node.js + // |   (1 hr) + //li + // a.disabled(href="/challenges/28", class="#{ cc.indexOf(27) > -1 ? 'strikethrough' : '' }") Clone a Github Repo + // |   (15 mins) + //li + // a.disabled(href="/challenges/29", class="#{ cc.indexOf(28) > -1 ? 'strikethrough' : '' }") Deploy an app to Heroku + // |   (15 mins) + //li + // a.disabled(href="/challenges/30", class="#{ cc.indexOf(29) > -1 ? 'strikethrough' : '' }") Code School's Real-time web with Node.JS + // |   (5 hrs) + //li + // a.disabled(href="/challenges/31", class="#{ cc.indexOf(30) > -1 ? 'strikethrough' : '' }") Try MongoDB + // |   (30 mins) + //li + // a.disabled(href="/challenges/32", class="#{ cc.indexOf(31) > -1 ? 'strikethrough' : '' }") Explore your Network with the LinkedIn API + // |   (1 hr) + //li + // a.disabled(href="/challenges/33", class="#{ cc.indexOf(32) > -1 ? 'strikethrough' : '' }") Build your first API + // |   (10 hrs | Pair) + //li + // a.disabled(href="/challenges/34", class="#{ cc.indexOf(33) > -1 ? 'strikethrough' : '' }") Aggregate Data with Chron Jobs and Screen Scraping + // |   (10 hrs | Pair) + //li + // a.disabled(href="/challenges/35", class="#{ cc.indexOf(34) > -1 ? 'strikethrough' : '' }") Code School's Shaping up with Angular.JS + // |   (5 hrs) + //li + // a.disabled(href="/challenges/36", class="#{ cc.indexOf(35) > -1 ? 'strikethrough' : '' }") Reverse Engineer SnapChat + // |   (50 hrs | Pair) + //li + // a.disabled(href="/challenges/37", class="#{ cc.indexOf(36) > -1 ? 'strikethrough' : '' }") Reverse Engineer Reddit + // |   (50 hrs | Pair) + //li + // a.disabled(href="/challenges/38", class="#{ cc.indexOf(37) > -1 ? 'strikethrough' : '' }") Reverse Engineer Pintrest + // |   (50 hrs | Pair) + //li + // a.disabled(href="/challenges/39", class="#{ cc.indexOf(38) > -1 ? 'strikethrough' : '' }") Help a Nonprofit: Team Project + // |   (150 hrs | Pair) + //li + // a.disabled(href="/challenges/40", class="#{ cc.indexOf(39) > -1 ? 'strikethrough' : '' }") Help a Nonprofit: Solo Project + // |   (150 hrs | Pair) + //li + // a.disabled(href="/challenges/41", class="#{ cc.indexOf(40) > -1 ? 'strikethrough' : '' }") Crack the Coding Interview + // |   (5 hrs) \ No newline at end of file diff --git a/views/partials/navbar.jade b/views/partials/navbar.jade index bfce8b0d1b..9fa4f46a35 100644 --- a/views/partials/navbar.jade +++ b/views/partials/navbar.jade @@ -20,7 +20,7 @@ img(src='#{user.profile.picture}') else img(src='#{user.gravatar(60)}') - | #{user.profile.name || user.email || user.id} [ #{user.challengesCompleted.length} ]  + | #{user.profile.name || user.email || user.id} [ #{Object.keys(user.challengesHash).length} ]  i.caret ul.dropdown-menu li