Skip to content
Permalink
Browse files

Merge branch 'develop' into greenkeeper/sinon-5.0.0

  • Loading branch information
paglias committed Apr 30, 2018
2 parents 11380b4 + 5f0ef2d commit f7775ce4f54b1baee3b353f2daf5abbafa4708e2
Showing 852 changed files with 25,790 additions and 20,387 deletions.
@@ -17,3 +17,4 @@ CHANGELOG.md
newrelic_agent.log
*.swp
*.swx
website/raw_sprites/**
@@ -1,8 +1,5 @@
FROM node:8

# Upgrade NPM to v5 (Yarn is needed because of this bug https://github.com/npm/npm/issues/16807)
# The used solution is suggested here https://github.com/npm/npm/issues/16807#issuecomment-313591975
RUN yarn global add npm@5
# Install global packages
RUN npm install -g gulp-cli mocha

@@ -11,16 +11,13 @@ ENV GOOGLE_CLIENT_ID 1035232791481-32vtplgnjnd1aufv3mcu1lthf31795fq.apps.googleu
ENV NODE_ENV production
ENV STRIPE_PUB_KEY pk_85fQ0yMECHNfHTSsZoxZXlPSwSNfA

# Upgrade NPM to v5 (Yarn is needed because of this bug https://github.com/npm/npm/issues/16807)
# The used solution is suggested here https://github.com/npm/npm/issues/16807#issuecomment-313591975
RUN yarn global add npm@5
# Install global packages
RUN npm install -g gulp-cli mocha

# Clone Habitica repo and install dependencies
RUN mkdir -p /usr/src/habitrpg
WORKDIR /usr/src/habitrpg
RUN git clone --branch v4.32.0 https://github.com/HabitRPG/habitica.git /usr/src/habitrpg
RUN git clone --branch v4.37.2 https://github.com/HabitRPG/habitica.git /usr/src/habitrpg
RUN npm install
RUN gulp build:prod --force

@@ -10,4 +10,3 @@ We need more programmers! Your assistance will be greatly appreciated.
For an introduction to the technologies used and how the software is organized, refer to [Guidance for Blacksmiths](http://habitica.wikia.com/wiki/Guidance_for_Blacksmiths).

To set up a local install of Habitica for development and testing on various platforms, see [Setting up Habitica Locally](http://habitica.wikia.com/wiki/Setting_up_Habitica_Locally).

@@ -98,9 +98,9 @@
},
"ITUNES_SHARED_SECRET": "aaaabbbbccccddddeeeeffff00001111",
"EMAILS" : {
"COMMUNITY_MANAGER_EMAIL" : "leslie@habitica.com",
"COMMUNITY_MANAGER_EMAIL" : "admin@habitica.com",
"TECH_ASSISTANCE_EMAIL" : "admin@habitica.com",
"PRESS_ENQUIRY_EMAIL" : "leslie@habitica.com"
"PRESS_ENQUIRY_EMAIL" : "admin@habitica.com"
},
"LOGGLY" : {
"TOKEN" : "example-token",
@@ -25,7 +25,7 @@ services:
- mongo

mongo:
image: mongo
image: mongo:3.4
ports:
- "27017:27017"
networks:
@@ -0,0 +1,52 @@
// @migrationName = 'MigrateGroupChat';
// @authorName = 'TheHollidayInn'; // in case script author needs to know when their ...
// @authorUuid = ''; // ... own data is done


/*
* This migration moves chat off of groups and into their own model
*/

import { model as Group } from '../../website/server/models/group';
import { model as Chat } from '../../website/server/models/chat';

async function moveGroupChatToModel (skip = 0) {
const groups = await Group.find({})
.limit(50)
.skip(skip)
.sort({ _id: -1 })
.exec();

if (groups.length === 0) {
console.log('End of groups');
process.exit();
}

const promises = groups.map(group => {
const chatpromises = group.chat.map(message => {
const newChat = new Chat();
Object.assign(newChat, message);
newChat._id = message.id;
newChat.groupId = group._id;

return newChat.save();
});

group.chat = [];
chatpromises.push(group.save());

return chatpromises;
});


const reducedPromises = promises.reduce((acc, curr) => {
acc = acc.concat(curr);
return acc;
}, []);

console.log(reducedPromises);
await Promise.all(reducedPromises);
moveGroupChatToModel(skip + 50);
}

module.exports = moveGroupChatToModel;
@@ -17,5 +17,5 @@ function setUpServer () {
setUpServer();

// Replace this with your migration
const processUsers = require('./20180125_clean_new_notifications.js');
const processUsers = require('./groups/migrate-chat.js');
processUsers();
@@ -0,0 +1,117 @@
import each from 'lodash/each';
import keys from 'lodash/keys';
import content from '../../website/common/script/content/index';
const migrationName = 'full-stable.js';
const authorName = 'Sabe'; // in case script author needs to know when their ...
const authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; // ... own data is done

/*
* Award users every extant pet and mount
*/
const connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE

let monk = require('monk');
let dbUsers = monk(connectionString).get('users', { castIds: false });

function processUsers (lastId) {
// specify a query to limit the affected users (empty for all users):
let query = {
'profile.name': 'SabreCat',
};

if (lastId) {
query._id = {
$gt: lastId,
};
}

dbUsers.find(query, {
sort: {_id: 1},
limit: 250,
fields: [
], // specify fields we are interested in to limit retrieved data (empty if we're not reading data):
})
.then(updateUsers)
.catch((err) => {
console.log(err);
return exiting(1, `ERROR! ${ err}`);
});
}

let progressCount = 1000;
let count = 0;

function updateUsers (users) {
if (!users || users.length === 0) {
console.warn('All appropriate users found and modified.');
displayData();
return;
}

let userPromises = users.map(updateUser);
let lastUser = users[users.length - 1];

return Promise.all(userPromises)
.then(() => {
processUsers(lastUser._id);
});
}

function updateUser (user) {
count++;
let set = {
migration: migrationName,
};

each(keys(content.pets), (pet) => {
set[`items.pets.${pet}`] = 5;
});
each(keys(content.premiumPets), (pet) => {
set[`items.pets.${pet}`] = 5;
});
each(keys(content.questPets), (pet) => {
set[`items.pets.${pet}`] = 5;
});
each(keys(content.specialPets), (pet) => {
set[`items.pets.${pet}`] = 5;
});
each(keys(content.mounts), (mount) => {
set[`items.mounts.${mount}`] = true;
});
each(keys(content.premiumMounts), (mount) => {
set[`items.mounts.${mount}`] = true;
});
each(keys(content.questMounts), (mount) => {
set[`items.mounts.${mount}`] = true;
});
each(keys(content.specialMounts), (mount) => {
set[`items.mounts.${mount}`] = true;
});

dbUsers.update({_id: user._id}, {$set: set});

if (count % progressCount === 0) console.warn(`${count } ${ user._id}`);
if (user._id === authorUuid) console.warn(`${authorName } processed`);
}

function displayData () {
console.warn(`\n${ count } users processed\n`);
return exiting(0);
}

function exiting (code, msg) {
code = code || 0; // 0 = success
if (code && !msg) {
msg = 'ERROR!';
}
if (msg) {
if (code) {
console.error(msg);
} else {
console.log(msg);
}
}
process.exit(code);
}

module.exports = processUsers;
@@ -5,7 +5,7 @@ const authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; // ... own data is do
/*
* Award this month's mystery items to subscribers
*/
const MYSTERY_ITEMS = ['armor_mystery_201802', 'head_mystery_201802', 'shield_mystery_201802'];
const MYSTERY_ITEMS = ['back_mystery_201804', 'headAccessory_mystery_201804'];
const connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE

let monk = require('monk');

0 comments on commit f7775ce

Please sign in to comment.
You can’t perform that action at this time.