chore(scripts): remove scripts for server specific logic (#2)
This commit is contained in:
committed by
GitHub
parent
d59514866e
commit
2cea1bdccc
@ -1,60 +0,0 @@
|
||||
require('babel-register');
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { Observable } = require('rx');
|
||||
const getChallenges = require('./getChallenges');
|
||||
const { dasherize } = require('../server/utils');
|
||||
|
||||
let pathMap = {};
|
||||
|
||||
function createPathMigrationMap() {
|
||||
return new Promise(resolve => {
|
||||
Observable.of(getChallenges())
|
||||
.map(blocks => {
|
||||
blocks.forEach(block => {
|
||||
const {name: blockName, superBlock, challenges } = block;
|
||||
if (!(dasherize(superBlock) in pathMap)) {
|
||||
pathMap[dasherize(superBlock)] = {};
|
||||
}
|
||||
if (!(dasherize(blockName) in pathMap[superBlock])) {
|
||||
pathMap[dasherize(superBlock)][dasherize(blockName)] = challenges
|
||||
.map(({ title, challengeType }) => ({
|
||||
dashedName: dasherize(title),
|
||||
challengeType
|
||||
}));
|
||||
}
|
||||
});
|
||||
})
|
||||
.subscribe(() => {}, console.error, () => {
|
||||
const migMap = Object.keys(pathMap)
|
||||
.filter(key => !key.includes('certificate'))
|
||||
.map(superBlock => {
|
||||
return Object.keys(pathMap[superBlock])
|
||||
.map(block => {
|
||||
return pathMap[superBlock][block]
|
||||
.reduce((map, {dashedName, challengeType}) => ({
|
||||
...map,
|
||||
[dashedName]: challengeType === 7 ?
|
||||
`/${superBlock}/${block}` :
|
||||
`/${superBlock}/${block}/${dashedName}`
|
||||
}), {});
|
||||
}).reduce((acc, current) => ({
|
||||
...acc,
|
||||
...current
|
||||
}), {});
|
||||
}).reduce((acc, current) => ({
|
||||
...acc,
|
||||
...current
|
||||
}), {});
|
||||
fs.writeFileSync(
|
||||
path.resolve(__dirname, '../server/resources/pathMigration.json'),
|
||||
JSON.stringify(migMap, null, 2)
|
||||
);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
exports.createPathMigrationMap = createPathMigrationMap;
|
@ -1,25 +0,0 @@
|
||||
/* eslint-disable no-process-exit */
|
||||
require('dotenv').load();
|
||||
var secrets = require('../config/secrets'),
|
||||
mongodb = require('mongodb'),
|
||||
MongoClient = mongodb.MongoClient;
|
||||
|
||||
MongoClient.connect(secrets.db, function(err, database) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
database.collection('user').aggregate([
|
||||
{$match: { 'email': { $exists: true } } },
|
||||
{$match: { 'email': { $ne: '' } } },
|
||||
{$match: { 'email': { $ne: null } } },
|
||||
{$match: { 'sendQuincyEmail': true } },
|
||||
{$match: { 'email': { $not: /(test|fake)/i } } },
|
||||
{$group: { '_id': 1, 'emails': {$addToSet: '$email' } } }
|
||||
], function(err, results) {
|
||||
if (err) { throw err; }
|
||||
|
||||
console.log('\"email\"\n\"' + results[0].emails.join('\"\n\"') + '\"');
|
||||
process.exit(0);
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user