Feature in dev mode always pull from disk

This commit is contained in:
Berkeley Martinez
2015-11-09 17:27:56 -08:00
parent 342640542f
commit d095fd5d90
7 changed files with 69 additions and 15 deletions

View File

@@ -4,7 +4,15 @@ import moment from 'moment';
import { Observable, Scheduler } from 'rx';
import assign from 'object.assign';
import debugFactory from 'debug';
import utils from '../utils';
import {
dasherize,
unDasherize,
getMDNLinks,
randomVerb,
randomPhrase,
randomCompliment
} from '../utils';
import {
saveUser,
@@ -16,6 +24,8 @@ import {
ifNoUserSend
} from '../utils/middleware';
import getFromDisk$ from '../utils/getFromDisk$';
const isDev = process.env.NODE_ENV !== 'production';
const isBeta = !!process.env.BETA;
const debug = debugFactory('freecc:challenges');
@@ -31,10 +41,6 @@ const challengeView = {
7: 'coursewares/showStep'
};
const dasherize = utils.dasherize;
const unDasherize = utils.unDasherize;
const getMDNLinks = utils.getMDNLinks;
/*
function makeChallengesUnique(challengeArr) {
// clone and reverse challenges
@@ -262,6 +268,12 @@ module.exports = function(app) {
return testChallengeName.test(challenge.name);
})
.last({ defaultValue: null })
.flatMap(challenge => {
if (challenge && isDev) {
return getFromDisk$(challenge);
}
return Observable.just(challenge);
})
.flatMap(challenge => {
// Handle not found
@@ -311,11 +323,9 @@ module.exports = function(app) {
MDNlinks: getMDNLinks(challenge.MDNlinks),
// htmls specific
environment: utils.whichEnvironment(),
verb: utils.randomVerb(),
phrase: utils.randomPhrase(),
compliment: utils.randomCompliment()
verb: randomVerb(),
phrase: randomPhrase(),
compliment: randomCompliment()
});
})
.subscribe(