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
This commit is contained in:
Quincy Larson
2016-04-25 16:57:30 -07:00
committed by Berkeley Martinez
parent 91d1cb528b
commit 6039d29282
2 changed files with 30 additions and 3 deletions

View File

@ -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,

View File

@ -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