2016-02-23 07:00:59 +00:00
|
|
|
import { Observable } from 'rx';
|
2016-01-15 08:10:13 +00:00
|
|
|
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');
|
|
|
|
|
2016-02-23 07:00:59 +00:00
|
|
|
Observable.combineLatest(
|
|
|
|
userCount$(),
|
|
|
|
userCount$({ isFrontEndCert: true }),
|
|
|
|
userCount$({ isDataVisCert: true }),
|
|
|
|
userCount$({ isBackEndCert: true }),
|
|
|
|
(
|
|
|
|
userCount,
|
|
|
|
frontEndCount = 0,
|
|
|
|
dataVisCount = 0,
|
|
|
|
backEndCount = 0
|
|
|
|
) => ({
|
|
|
|
userCount: numberWithCommas(userCount),
|
|
|
|
frontEndCount,
|
|
|
|
dataVisCount,
|
|
|
|
backEndCount
|
|
|
|
})
|
|
|
|
)
|
|
|
|
.doOnNext(({ userCount, frontEndCount, dataVisCount, backEndCount }) => {
|
2016-01-15 08:10:13 +00:00
|
|
|
res.render('resources/about', {
|
2016-02-23 07:00:59 +00:00
|
|
|
userCount,
|
|
|
|
frontEndCount,
|
|
|
|
dataVisCount,
|
|
|
|
backEndCount,
|
2016-01-15 08:10:13 +00:00
|
|
|
daysRunning,
|
|
|
|
title: dedent`
|
|
|
|
About our Open Source Community, our social media presence,
|
2016-02-23 06:28:32 +00:00
|
|
|
and how to contact us
|
|
|
|
`.split('\n').join(' '),
|
2016-01-15 08:10:13 +00:00
|
|
|
globalCompletedCount: numberWithCommas(
|
2016-02-23 06:28:32 +00:00
|
|
|
5612952 + (Math.floor((Date.now() - 1446268581061) / 1800))
|
2016-02-23 06:15:14 +00:00
|
|
|
),
|
2016-02-23 06:32:50 +00:00
|
|
|
globalPledgedAmount: numberWithCommas(Math.floor(
|
|
|
|
28000 +
|
|
|
|
((Date.now() - 1456207176902) / (2629746000 / 2000) * 8.30)
|
|
|
|
))
|
2016-01-15 08:10:13 +00:00
|
|
|
});
|
|
|
|
})
|
|
|
|
.subscribe(() => {}, next);
|
|
|
|
}
|
|
|
|
|
|
|
|
router.get('/about', showAbout);
|
|
|
|
app.use(router);
|
|
|
|
}
|