mirror of
https://github.com/Lissy93/happy-app.git
synced 2021-05-12 19:52:18 +03:00
Cleaned up basic linting in task files a bit
This commit is contained in:
@@ -1,14 +1,13 @@
|
|||||||
|
|
||||||
import gulp from "gulp";
|
import gulp from "gulp";
|
||||||
|
|
||||||
import {tasks} from "./client/const";
|
import {tasks} from "./client/const";
|
||||||
|
|
||||||
gulp.task("default", [tasks.CLIENT_WATCH]);
|
gulp.task("default", [tasks.CLIENT_WATCH]);
|
||||||
|
|
||||||
require("require-dir")("client");
|
require("require-dir")("client");
|
||||||
|
|
||||||
|
|
||||||
require("require-dir")("server");
|
require("require-dir")("server");
|
||||||
|
|
||||||
|
|
||||||
require("./setup/index");
|
require("./setup/index");
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,29 @@
|
|||||||
import gulp from "gulp";
|
import gulp from "gulp";
|
||||||
|
|
||||||
|
/* Include gulp scripts, which do stuff */
|
||||||
const populateDemoDb = require('./populate-demo-db');
|
const populateDemoDb = require('./populate-demo-db');
|
||||||
const deleteDemoDb = require('./delete-demo-db');
|
const deleteDemoDb = require('./delete-demo-db');
|
||||||
const populateDemoTeamMembers = require('./populate-demo-team-members');
|
const populateDemoTeamMembers = require('./populate-demo-team-members');
|
||||||
|
|
||||||
|
/**
|
||||||
gulp.task('populate-sample-data', () => {
|
* Deletes current DB
|
||||||
populateDemoDb();
|
* USE WITH CAUTION (obvs!)
|
||||||
});
|
*/
|
||||||
|
|
||||||
gulp.task('delete-database', () => {
|
gulp.task('delete-database', () => {
|
||||||
deleteDemoDb(()=>{});
|
deleteDemoDb(()=>{});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populates random team data from scratch
|
||||||
|
*/
|
||||||
|
gulp.task('populate-sample-data', () => {
|
||||||
|
populateDemoDb();
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populates a random team config file
|
||||||
|
* optionally BASED on the random sample data already populated
|
||||||
|
*/
|
||||||
gulp.task('populate-demo-team-members', () => {
|
gulp.task('populate-demo-team-members', () => {
|
||||||
populateDemoTeamMembers(()=>{});
|
populateDemoTeamMembers(()=>{});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ DBConfig.init();
|
|||||||
// The schema for TeamRecord, that data is formated to, before insert
|
// The schema for TeamRecord, that data is formated to, before insert
|
||||||
const TeamRecordSchema = require('../../server/api/records/record.model');
|
const TeamRecordSchema = require('../../server/api/records/record.model');
|
||||||
|
|
||||||
|
// Includes common helper functions
|
||||||
import Helpers from '../../server/commons/helpers';
|
import Helpers from '../../server/commons/helpers';
|
||||||
|
|
||||||
|
|
||||||
@@ -33,7 +34,6 @@ function executeInsertScript(sampleDataLocation = undefined){
|
|||||||
const randomSampleData = generateSomeRandomSampleData();
|
const randomSampleData = generateSomeRandomSampleData();
|
||||||
insertJsonData(randomSampleData);
|
insertJsonData(randomSampleData);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -76,7 +76,6 @@ function cleanUp(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a set of random sample data
|
* Generates a set of random sample data
|
||||||
*/
|
*/
|
||||||
@@ -96,7 +95,7 @@ function generateSomeRandomSampleData(){
|
|||||||
'acceptance criteria still to vague', 'unrealistic story estimates', 'not so good'];
|
'acceptance criteria still to vague', 'unrealistic story estimates', 'not so good'];
|
||||||
|
|
||||||
// Format and pad out the positive and negative comments
|
// Format and pad out the positive and negative comments
|
||||||
const blanks = Array.apply(null, Array(300)).map(String.prototype.valueOf,'');
|
const blanks = Array.apply(null, new Array(300)).map(String.prototype.valueOf,'');
|
||||||
positiveComments = shuffle(positiveComments.concat(blanks));
|
positiveComments = shuffle(positiveComments.concat(blanks));
|
||||||
negativeComments = shuffle(negativeComments.concat(blanks));
|
negativeComments = shuffle(negativeComments.concat(blanks));
|
||||||
|
|
||||||
@@ -130,13 +129,13 @@ function generateSomeRandomSampleData(){
|
|||||||
function makeLessRandomMoods(){
|
function makeLessRandomMoods(){
|
||||||
let todaysMoods = [];
|
let todaysMoods = [];
|
||||||
moods.forEach((mood)=>{
|
moods.forEach((mood)=>{
|
||||||
let newMs = Array.apply(null,Array(getNumInRange(numMoods))).map(String.prototype.valueOf, mood);
|
let newMs = Array.apply(null, new Array(getNumInRange(numMoods))).map(String.prototype.valueOf, mood);
|
||||||
newMs.forEach((m)=> todaysMoods.push(m));
|
newMs.forEach((m)=> todaysMoods.push(m));
|
||||||
});
|
});
|
||||||
return todaysMoods;
|
return todaysMoods;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shuffles a given array
|
/* Shuffles a given array */
|
||||||
function shuffle(array) {
|
function shuffle(array) {
|
||||||
let currentIndex = array.length, temporaryValue, randomIndex;
|
let currentIndex = array.length, temporaryValue, randomIndex;
|
||||||
while (0 !== currentIndex) {
|
while (0 !== currentIndex) {
|
||||||
@@ -165,8 +164,8 @@ function generateSomeRandomSampleData(){
|
|||||||
let userHash = makeFakeUserHash(userNum);
|
let userHash = makeFakeUserHash(userNum);
|
||||||
let mood = getRandomElemFromArr(todaysMoods);
|
let mood = getRandomElemFromArr(todaysMoods);
|
||||||
let comment = '';
|
let comment = '';
|
||||||
if(mood == 'good'){ comment = getRandomElemFromArr(positiveComments); }
|
if(mood === 'good'){ comment = getRandomElemFromArr(positiveComments); }
|
||||||
else if(mood == 'bad'){ comment = getRandomElemFromArr(negativeComments); }
|
else if(mood === 'bad'){ comment = getRandomElemFromArr(negativeComments); }
|
||||||
userResults.push({userHash: userHash, score: mood, comment: comment})
|
userResults.push({userHash: userHash, score: mood, comment: comment})
|
||||||
}
|
}
|
||||||
dataArr.push({date: date, userResults: userResults});
|
dataArr.push({date: date, userResults: userResults});
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
|
|
||||||
// Import the Mongo config, then connect (by calling init())
|
/* Import the Mongo stuff, then connect (by calling init()) */
|
||||||
import DBConfig from '../../server/config/db.conf';
|
import DBConfig from '../../server/config/db.conf';
|
||||||
const TeamRecordModel = require('../../server/api/records/record.model');
|
const TeamRecordModel = require('../../server/api/records/record.model');
|
||||||
DBConfig.init();
|
DBConfig.init();
|
||||||
|
|
||||||
|
/* The schema for TeamRecord, that data is formated to, before insert */
|
||||||
// The schema for TeamRecord, that data is formated to, before insert
|
|
||||||
const TeamMembersSchema = require('../../server/api/teams/team-members.model');
|
const TeamMembersSchema = require('../../server/api/teams/team-members.model');
|
||||||
|
|
||||||
|
|
||||||
@@ -20,7 +19,7 @@ function executeInsertScript(sampleDataLocation = undefined){
|
|||||||
|
|
||||||
sampleDataLocation = undefined; //todo investigate, then delete
|
sampleDataLocation = undefined; //todo investigate, then delete
|
||||||
|
|
||||||
// If sample data specified, then read it, and insert into db
|
/* If sample data specified, then read it, and insert into db */
|
||||||
if(sampleDataLocation){
|
if(sampleDataLocation){
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
fs.readFile(sampleDataLocation, function read(err, data) {
|
fs.readFile(sampleDataLocation, function read(err, data) {
|
||||||
@@ -29,21 +28,21 @@ function executeInsertScript(sampleDataLocation = undefined){
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no data, then call generate new sample data, then insert into db
|
/* If no data, then call generate new sample data, then insert into db */
|
||||||
else{
|
else{
|
||||||
|
|
||||||
// Fetch current team names
|
/* Fetch current team names */
|
||||||
let teamNames = [];
|
let teamNames = [];
|
||||||
TeamRecordModel.find({}, function(err, teams) {
|
TeamRecordModel.find({}, function(err, teams) {
|
||||||
teams.forEach((team)=> teamNames.push(team.teamName));
|
teams.forEach((team)=> teamNames.push(team.teamName));
|
||||||
|
|
||||||
// If no team names were returned, then undefined will cause us to use defaults
|
/* If no team names were returned, then undefined will cause us to use defaults */
|
||||||
if(err || teamNames.length < 1) teamNames = undefined;
|
if(err || teamNames.length < 1) teamNames = undefined;
|
||||||
|
|
||||||
// Generate the rest of the sample responses
|
/* Generate the rest of the sample responses */
|
||||||
const randomSampleData = generateSomeRandomSampleData(teamNames);
|
const randomSampleData = generateSomeRandomSampleData(teamNames);
|
||||||
|
|
||||||
// And finally, insert into the db
|
/* And finally, insert into the db */
|
||||||
insertJsonData(randomSampleData);
|
insertJsonData(randomSampleData);
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -60,7 +59,7 @@ function executeInsertScript(sampleDataLocation = undefined){
|
|||||||
*/
|
*/
|
||||||
function insertJsonData (jsonData) {
|
function insertJsonData (jsonData) {
|
||||||
|
|
||||||
// Set of a promise for each team record
|
/* Set of a promise for each team record */
|
||||||
let promises = jsonData.map(function(teamData) {
|
let promises = jsonData.map(function(teamData) {
|
||||||
return new Promise(function(resolve) {
|
return new Promise(function(resolve) {
|
||||||
let teamObject = new TeamMembersSchema(teamData);
|
let teamObject = new TeamMembersSchema(teamData);
|
||||||
@@ -72,7 +71,7 @@ function insertJsonData (jsonData) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// When all promises have resolved
|
/* When all promises have resolved */
|
||||||
Promise.all(promises)
|
Promise.all(promises)
|
||||||
.then(cleanUp)
|
.then(cleanUp)
|
||||||
.catch(console.error);
|
.catch(console.error);
|
||||||
@@ -90,39 +89,38 @@ function cleanUp(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a set of random sample data
|
* Generates a set of random sample data
|
||||||
*/
|
*/
|
||||||
function generateSomeRandomSampleData(teamNames = undefined){
|
function generateSomeRandomSampleData(teamNames = undefined){
|
||||||
|
|
||||||
// Set the team names (if they weren't passed as a parameter)
|
/* Set the team names (if they weren't passed as a parameter) */
|
||||||
if (!teamNames){
|
if (!teamNames){
|
||||||
teamNames = ['atlanta', 'brisbane', 'budapest', 'chicago', 'delhi',
|
teamNames = ['atlanta', 'brisbane', 'budapest', 'chicago', 'delhi',
|
||||||
'detroit', 'istanbul', 'lisbon', 'london', 'mexico', 'mumbai', 'paris',
|
'detroit', 'istanbul', 'lisbon', 'london', 'mexico', 'mumbai', 'paris',
|
||||||
'rio', 'rome', 'san-francisco', 'tokyo', 'vancouver', 'vienna'];
|
'rio', 'rome', 'san-francisco', 'tokyo', 'vancouver', 'vienna'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define some ranges
|
/* Define some ranges */
|
||||||
const numTeams = {min: 4, max: 6 }; // The number of teams to generate
|
const numTeams = {min: 4, max: 6 }; // The number of teams to generate
|
||||||
const numUsers = {min: 6, max: 30}; // The number of user responses per day
|
const numUsers = {min: 6, max: 30}; // The number of user responses per day
|
||||||
|
|
||||||
// Takes {min: x, max: y} object and returns int within range
|
/* Takes {min: x, max: y} object and returns int within range */
|
||||||
function getNumInRange(range){
|
function getNumInRange(range){
|
||||||
return Math.floor(Math.random() * (range.max - range.min + 1)) + range.min;
|
return Math.floor(Math.random() * (range.max - range.min + 1)) + range.min;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a certain number (num) or elements from a given array (arr)
|
/* Returns a certain number (num) or elements from a given array (arr) */
|
||||||
function getRandomSnippetFromArr(arr, num){
|
function getRandomSnippetFromArr(arr, num){
|
||||||
return shuffle(arr).splice(0, num);
|
return shuffle(arr).splice(0, num);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a random element from given array
|
/* Returns a random element from given array */
|
||||||
function getRandomElemFromArr(arr){
|
function getRandomElemFromArr(arr){
|
||||||
return shuffle(arr)[0];
|
return shuffle(arr)[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shuffles a given array
|
/* Shuffles a given array */
|
||||||
function shuffle(array) {
|
function shuffle(array) {
|
||||||
let currentIndex = array.length, temporaryValue, randomIndex;
|
let currentIndex = array.length, temporaryValue, randomIndex;
|
||||||
while (0 !== currentIndex) {
|
while (0 !== currentIndex) {
|
||||||
|
|||||||
Reference in New Issue
Block a user