chore: Delete unrequired files

This commit is contained in:
Bouncey
2019-02-16 00:26:42 +00:00
committed by mrugesh mohapatra
parent 36d150cbe1
commit f441b1fe1c
4 changed files with 0 additions and 241 deletions

View File

@ -1,58 +0,0 @@
import debug from 'debug';
import { pickBy } from 'lodash';
import { Observable } from 'rx';
import { cachedMap, getChallenge } from '../utils/map';
import { shapeChallenges } from '../../common/app/redux/utils';
const log = debug('fcc:services:challenge');
const isDev = debug.enabled('fcc:*');
export default function getChallengesForBlock(app) {
const challengeMap = cachedMap(app.models);
return {
name: 'challenge',
read: function readChallengesForBlock(
req,
resource,
{ dashedName, blockName} = {},
config,
cb
) {
const getChallengeBlock$ = challengeMap
.flatMap(({
result: { superBlocks },
entities: {
block: fullBlockMap,
challenge: challengeMap
}
}) => {
log(`sourcing challenges for the ${blockName} block`);
const requestedChallenges = pickBy(
challengeMap,
ch => ch.block === blockName
);
const entities = {
block: {
[blockName]: fullBlockMap[blockName]
},
challenge: requestedChallenges
};
const { challenge, block } = shapeChallenges(entities, isDev);
return Observable.of({
result: { superBlocks },
entities: { challenge, block }
});
});
return Observable.if(
() => !!dashedName,
getChallenge(dashedName, blockName, challengeMap, 'en'),
getChallengeBlock$
)
.subscribe(
result => cb(null, result),
cb
);
}
};
}

View File

@ -1,86 +0,0 @@
import debug from 'debug';
import { Observable } from 'rx';
import { cachedMap } from '../utils/map';
const log = debug('fcc:services:mapUi');
export default function mapUiService(app) {
const challengeMap = cachedMap(app.models);
return {
name: 'map-ui',
read: function readMapUi(req, resource, _, config, cb) {
return challengeMap
.flatMap(({
result: { superBlocks },
entities: {
superBlock: fullSuperBlockMap,
block: fullBlockMap,
challenge: fullChallengeMap
}
}) => {
const superBlockMap = superBlocks
.map(superBlock => fullSuperBlockMap[superBlock])
.reduce((map, { dashedName, blocks, title }) => {
map[dashedName] = { blocks, title, dashedName};
return map;
}, {});
const blockMap = Object.keys(fullBlockMap)
.map(block => fullBlockMap[block])
.reduce(
(map, { dashedName, title, time, challenges, superBlock }) => {
map[dashedName] = {
dashedName,
title,
time,
challenges,
superBlock
};
return map;
},
{}
);
const challengeMap = Object.keys(fullChallengeMap)
.map(challenge => fullChallengeMap[challenge])
.reduce((map, challenge) => {
const {
dashedName,
id,
title,
name,
block,
isLocked,
isComingSoon,
isBeta,
challengeType
} = challenge;
map[dashedName] = {
dashedName,
id,
title,
name,
block,
isLocked,
isComingSoon,
isBeta,
challengeType
};
return map;
}, {});
const mapUi = {
result: { superBlocks },
entities: {
superBlock: superBlockMap,
block: blockMap,
challenge: challengeMap
}
};
return Observable.of(mapUi);
}).subscribe(
mapUi => cb(null, mapUi ),
err => { log(err); return cb(err); }
);
}
};
}

View File

@ -1,72 +0,0 @@
/**
*
* Any ref to fixCompletedChallengesItem should be removed post
* a db migration to fix all completedChallenges
*
*/
import { Observable } from 'rx';
import _ from 'lodash';
import {
getProgress,
normaliseUserFields,
userPropsForSession
} from '../utils/publicUserProps';
import { fixCompletedChallengeItem } from '../../common/utils';
export default function userServices() {
return {
name: 'user',
read: function readUserService(
req,
resource,
params,
config,
cb) {
const queryUser = req.user;
const source = queryUser && Observable.forkJoin(
queryUser.getCompletedChallenges$(),
queryUser.getPoints$(),
(completedChallenges, progressTimestamps) => ({
completedChallenges,
progress: getProgress(progressTimestamps, queryUser.timezone)
})
);
Observable.if(
() => !queryUser,
Observable.of({}),
Observable.defer(() => source)
.map(({ completedChallenges, progress }) => ({
...queryUser.toJSON(),
...progress,
completedChallenges: completedChallenges.map(
fixCompletedChallengeItem
)
}))
.map(
user => ({
entities: {
user: {
[user.username]: {
..._.pick(user, userPropsForSession),
isEmailVerified: !!user.emailVerified,
isGithub: !!user.githubProfile,
isLinkedIn: !!user.linkedin,
isTwitter: !!user.twitter,
isWebsite: !!user.website,
...normaliseUserFields(user)
}
}
},
result: user.username
})
)
)
.subscribe(
user => cb(null, user),
cb
);
}
};
}