forked from freeCodeCamp/freeCodeCamp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Berkeley Martinez
authored and
Berkeley Martinez
committed
Jan 15, 2016
1 parent
a6c4ed7
commit 918ea56
Showing
4 changed files
with
57 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import dedent from 'dedent'; | ||
import moment from 'moment'; | ||
|
||
import { observeMethod } from '../utils/rx'; | ||
|
||
function numberWithCommas(x) { | ||
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); | ||
} | ||
|
||
export default function about(app) { | ||
const router = app.loopback.Router(); | ||
const User = app.models.User; | ||
const userCount$ = observeMethod(User, 'count'); | ||
|
||
function showAbout(req, res, next) { | ||
const daysRunning = moment().diff(new Date('10/15/2014'), 'days'); | ||
|
||
userCount$() | ||
.map(camperCount => numberWithCommas(camperCount)) | ||
.doOnNext(camperCount => { | ||
res.render('resources/about', { | ||
camperCount, | ||
daysRunning, | ||
title: dedent` | ||
About our Open Source Community, our social media presence, | ||
and how to contact us`.split('\n').join(' '), | ||
globalCompletedCount: numberWithCommas( | ||
5612952 + (Math.floor((Date.now() - 1446268581061) / 2000)) | ||
) | ||
}); | ||
}) | ||
.subscribe(() => {}, next); | ||
} | ||
|
||
router.get('/about', showAbout); | ||
app.use(router); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters