From 2cea1bdccc949aac2a11eeff5335dbff761af661 Mon Sep 17 00:00:00 2001 From: mrugesh mohapatra Date: Sat, 9 Jun 2018 04:12:17 +0530 Subject: [PATCH] chore(scripts): remove scripts for server specific logic (#2) --- createPathMigrationMap.js | 60 --------------------------------------- get-emails.js | 25 ---------------- 2 files changed, 85 deletions(-) delete mode 100644 createPathMigrationMap.js delete mode 100644 get-emails.js diff --git a/createPathMigrationMap.js b/createPathMigrationMap.js deleted file mode 100644 index b904063093..0000000000 --- a/createPathMigrationMap.js +++ /dev/null @@ -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; diff --git a/get-emails.js b/get-emails.js deleted file mode 100644 index bc9cfd6525..0000000000 --- a/get-emails.js +++ /dev/null @@ -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); - }); -});