set last completed block in map view

This commit is contained in:
Berkeley Martinez
2015-09-28 19:20:29 -07:00
parent 1ff55374db
commit 6a5bea67f7
2 changed files with 11 additions and 2 deletions

View File

@ -471,6 +471,7 @@ module.exports = function(app) {
} }
function challengeMap({ user = {} }, res, next) { function challengeMap({ user = {} }, res, next) {
let lastCompleted;
const daysRunning = moment().diff(new Date('10/15/2014'), 'days'); const daysRunning = moment().diff(new Date('10/15/2014'), 'days');
// if user // if user
@ -513,7 +514,13 @@ module.exports = function(app) {
}) })
.filter(({ name }) => name !== 'Hikes') .filter(({ name }) => name !== 'Hikes')
// turn stream of blocks into a stream of an array // turn stream of blocks into a stream of an array
.toArray(); .toArray()
.doOnNext((blocks) => {
const lastCompletedBlock = _.findLast(blocks, (block) => {
return block.completed === 100;
});
lastCompleted = lastCompletedBlock.name;
});
Observable.combineLatest( Observable.combineLatest(
camperCount$, camperCount$,
@ -526,6 +533,7 @@ module.exports = function(app) {
blocks, blocks,
daysRunning, daysRunning,
camperCount, camperCount,
lastCompleted,
title: "A map of all Free Code Camp's Challenges" title: "A map of all Free Code Camp's Challenges"
}); });
}, },

View File

@ -138,7 +138,8 @@ block content
a.btn.btn-lg.btn-block.signup-btn.map-challenge-block-share Section complete. Share your Portfolio with your friends. a.btn.btn-lg.btn-block.signup-btn.map-challenge-block-share Section complete. Share your Portfolio with your friends.
.hidden(id="#{challengeBlock.name}") .hidden(id="#{challengeBlock.name}")
script. script.
var username = !{JSON.stringify(user && user.username || "")}; var username = !{JSON.stringify(user && user.username || '')};
var lastCompleted = !{JSON.stringify(lastCompleted || false)}
// #announcementModal.modal(tabindex='-1') // #announcementModal.modal(tabindex='-1')
// .modal-dialog.animated.fadeInUp.fast-animation // .modal-dialog.animated.fadeInUp.fast-animation
// .modal-content // .modal-content