From 6039d29282ad8687e1fe35cb778de7bb742eff19 Mon Sep 17 00:00:00 2001 From: Quincy Larson Date: Mon, 25 Apr 2016 16:57:30 -0700 Subject: [PATCH] Add count of campers who have earned all three certs to about page (#8288) * add count of campers who have earned all three certs to about page * refactor to get tests to pass --- server/boot/about.js | 29 ++++++++++++++++++++++++++--- server/views/resources/about.jade | 4 ++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/server/boot/about.js b/server/boot/about.js index 7e596394f3..4c58825eea 100644 --- a/server/boot/about.js +++ b/server/boot/about.js @@ -16,6 +16,15 @@ function getCertCount(userCount, cert) { ::timeCache(2, 'hours'); } +function getAllThreeCertsCount(userCount) { + return userCount({ + isFrontEndCert: true, + isDataVisCert: true, + isBackEndCert: true + }) + ::timeCache(2, 'hours'); +} + export default function about(app) { const router = app.loopback.Router(); const User = app.models.User; @@ -23,6 +32,7 @@ export default function about(app) { const frontEndCount$ = getCertCount(userCount, 'isFrontEndCert'); const dataVisCount$ = getCertCount(userCount, 'isDataVisCert'); const backEndCount$ = getCertCount(userCount, 'isBackEndCert'); + const allThreeCount$ = getAllThreeCertsCount(userCount); function showAbout(req, res, next) { const daysRunning = moment().diff(new Date('10/15/2014'), 'days'); @@ -31,17 +41,30 @@ export default function about(app) { frontEndCount$, dataVisCount$, backEndCount$, - (frontEndCount = 0, dataVisCount = 0, backEndCount = 0) => ({ + allThreeCount$, + ( + frontEndCount = 0, + dataVisCount = 0, + backEndCount = 0, + allThreeCount = 0 + ) => ({ frontEndCount, dataVisCount, - backEndCount + backEndCount, + allThreeCount }) ) - .doOnNext(({ frontEndCount, dataVisCount, backEndCount }) => { + .doOnNext(({ + frontEndCount, + dataVisCount, + backEndCount, + allThreeCount + }) => { res.render('resources/about', { frontEndCount: numberWithCommas(frontEndCount), dataVisCount: numberWithCommas(dataVisCount), backEndCount: numberWithCommas(backEndCount), + allThreeCount: numberWithCommas(allThreeCount), daysRunning, title: dedent` About our Open Source Community, our social media presence, diff --git a/server/views/resources/about.jade b/server/views/resources/about.jade index d80eab4a32..a4d00fb9f3 100644 --- a/server/views/resources/about.jade +++ b/server/views/resources/about.jade @@ -38,6 +38,10 @@ block content span.tag Back End: span.text-primary #{backEndCount} | earned + li.nowrap + span.tag All three: + span.text-primary #{allThreeCount} + | earned .spacer .row .col-xs-12.col-sm-10.col-sm-offset-1.col-md-6.col-md-offset-3