mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-10-26 10:42:52 +01:00
Compare commits
211 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2db3ac7bd3 | ||
|
|
201ec0e865 | ||
|
|
a0253cf289 | ||
|
|
5256569bac | ||
|
|
16524d4464 | ||
|
|
63a11c6c28 | ||
|
|
b5dfa54052 | ||
|
|
2e7deffb69 | ||
|
|
535c41dba8 | ||
|
|
7357fb0528 | ||
|
|
49e67fa87c | ||
|
|
b4ca425562 | ||
|
|
deba726afa | ||
|
|
2abf0f4900 | ||
|
|
0c3b4bba51 | ||
|
|
09948ba319 | ||
|
|
da50d2f495 | ||
|
|
716393cf91 | ||
|
|
fe102aedd3 | ||
|
|
cf7fc8d578 | ||
|
|
b39a5be2d1 | ||
|
|
45a1ad501e | ||
|
|
2959f0afab | ||
|
|
77f8c45e08 | ||
|
|
bd2fea6e81 | ||
|
|
cb7f85037f | ||
|
|
a9db5310cc | ||
|
|
49af418a29 | ||
|
|
dee81ee6c9 | ||
|
|
5265e6d321 | ||
|
|
5e5d73816b | ||
|
|
3e723ec4de | ||
|
|
892ba3b741 | ||
|
|
48e556fa54 | ||
|
|
f687c6f987 | ||
|
|
0b4eafeb28 | ||
|
|
cedfc005f8 | ||
|
|
be71c5f844 | ||
|
|
7dcd550209 | ||
|
|
6118336a5d | ||
|
|
01dab33b96 | ||
|
|
84dc2f8e3c | ||
|
|
b1bd243892 | ||
|
|
67961be575 | ||
|
|
4b17f62241 | ||
|
|
b850ea9dbf | ||
|
|
94e615e53e | ||
|
|
3a1e56cc8e | ||
|
|
cea47e5280 | ||
|
|
9ccb60799e | ||
|
|
f86a77608b | ||
|
|
8b8cee40a7 | ||
|
|
9487811d31 | ||
|
|
d5e4be85e9 | ||
|
|
deaf7fee81 | ||
|
|
72dc7c01c3 | ||
|
|
00c830372a | ||
|
|
199ca03b23 | ||
|
|
84dc1ab546 | ||
|
|
91df5d1565 | ||
|
|
d0a05ad745 | ||
|
|
c991a3e20f | ||
|
|
93cfd59ea1 | ||
|
|
695f53758a | ||
|
|
416c24d1e2 | ||
|
|
b0974fc4fc | ||
|
|
8fabadfc67 | ||
|
|
f2e5fdddf1 | ||
|
|
9919faeed8 | ||
|
|
f592103754 | ||
|
|
80e4f5e745 | ||
|
|
119f21ddce | ||
|
|
311a898938 | ||
|
|
1c1b050e2c | ||
|
|
faa068f690 | ||
|
|
b619496f8e | ||
|
|
80fe58bc6f | ||
|
|
c3c9dd5d35 | ||
|
|
464613a56a | ||
|
|
74ba55c20b | ||
|
|
ee087e5eee | ||
|
|
95179be346 | ||
|
|
b0ae0ef4da | ||
|
|
dad4f864ff | ||
|
|
f7ffc173b1 | ||
|
|
ac6a5ae8d2 | ||
|
|
70fbc83664 | ||
|
|
c3e41cc5e1 | ||
|
|
cae0120beb | ||
|
|
10b978da4e | ||
|
|
5987145b86 | ||
|
|
791d711298 | ||
|
|
ff65c4da78 | ||
|
|
163d56afe9 | ||
|
|
2f46d1bc65 | ||
|
|
6ccb841b32 | ||
|
|
cdcee8d169 | ||
|
|
16a227109e | ||
|
|
8611bd97ae | ||
|
|
2f3e6b82cf | ||
|
|
adcd9a53c4 | ||
|
|
4a7eb768dc | ||
|
|
d544a5be6f | ||
|
|
269dac1fe8 | ||
|
|
bd90ffa6f8 | ||
|
|
7c5d35cf77 | ||
|
|
0049647c08 | ||
|
|
7684f9b26a | ||
|
|
fd5ab32c43 | ||
|
|
e0933dc0a1 | ||
|
|
d69e7e66ee | ||
|
|
fa06628361 | ||
|
|
7f1067e1ab | ||
|
|
db6644a572 | ||
|
|
1e23395c8c | ||
|
|
b7b8faedd6 | ||
|
|
7da0b641dd | ||
|
|
82ff241e39 | ||
|
|
cf4aaf1618 | ||
|
|
6a67cbba65 | ||
|
|
037280601a | ||
|
|
2687fe1ac9 | ||
|
|
31eeb13598 | ||
|
|
818c201afe | ||
|
|
54153ec299 | ||
|
|
7abfd1d510 | ||
|
|
b4cbcb172b | ||
|
|
f78bcc20c9 | ||
|
|
6506f1d44d | ||
|
|
6cb1ec4ec5 | ||
|
|
723b4f3451 | ||
|
|
6c677be9d2 | ||
|
|
f49c99ee06 | ||
|
|
846feb1902 | ||
|
|
da22858ac0 | ||
|
|
dafb6df18b | ||
|
|
9017eea0c4 | ||
|
|
92abb19f9c | ||
|
|
3bee0446b8 | ||
|
|
1ed58c452c | ||
|
|
f947d3562b | ||
|
|
8e24b0578e | ||
|
|
f87d6e3b31 | ||
|
|
e1e5a6cc34 | ||
|
|
9eb70ee9ba | ||
|
|
7485300ee9 | ||
|
|
762c202154 | ||
|
|
7613e50917 | ||
|
|
4c77434bf0 | ||
|
|
1ab26a200e | ||
|
|
b738824f76 | ||
|
|
694c440b55 | ||
|
|
667bb28fe3 | ||
|
|
8993337ad7 | ||
|
|
a251a5d089 | ||
|
|
dcdeec6256 | ||
|
|
9fd0df9f2f | ||
|
|
1061fb0c31 | ||
|
|
c14fdd3fed | ||
|
|
e219ad6bdf | ||
|
|
42d7fd0861 | ||
|
|
7ade91a8b8 | ||
|
|
7c6dd6a6bd | ||
|
|
9a00779698 | ||
|
|
a61d911c48 | ||
|
|
fbacb56700 | ||
|
|
185717e6c3 | ||
|
|
505dd4969d | ||
|
|
944e4fe399 | ||
|
|
804dd087f8 | ||
|
|
cb1136aadc | ||
|
|
0f4b8f5f30 | ||
|
|
2d612b655d | ||
|
|
46877fb20c | ||
|
|
38cded2083 | ||
|
|
65074df668 | ||
|
|
b0ab09c352 | ||
|
|
3a60e8de66 | ||
|
|
886a96dac9 | ||
|
|
20556e2af4 | ||
|
|
3e849ec9a8 | ||
|
|
03946e6a87 | ||
|
|
fdcc69fe4a | ||
|
|
322b6a5e44 | ||
|
|
2243a2f3dc | ||
|
|
59c848add5 | ||
|
|
2d6a1fe709 | ||
|
|
fac0338437 | ||
|
|
e46f30894c | ||
|
|
553dc116c5 | ||
|
|
2029cd884c | ||
|
|
ab89941ed5 | ||
|
|
5dc0f5bb9b | ||
|
|
d46a7ba985 | ||
|
|
86b3228a59 | ||
|
|
4efbbd7bac | ||
|
|
d39e8a3587 | ||
|
|
8bd3ef6f24 | ||
|
|
6d0917964b | ||
|
|
d463e2373e | ||
|
|
2af99d7c65 | ||
|
|
4e01b14874 | ||
|
|
944781c2f8 | ||
|
|
027eed1b25 | ||
|
|
803f63d991 | ||
|
|
78ad1cd8b0 | ||
|
|
a3ddd0746c | ||
|
|
94845ec629 | ||
|
|
3727d69d51 | ||
|
|
1fbdb7dbd0 | ||
|
|
389d6f18b4 |
@@ -10,12 +10,5 @@ apidoc_build/
|
||||
content_cache/
|
||||
node_modules/
|
||||
|
||||
# Not linted
|
||||
website/client-old/
|
||||
test/client-old/spec/**/*
|
||||
|
||||
# Temporarilly disabled. These should be removed when the linting errors are fixed TODO
|
||||
migrations/*
|
||||
scripts/*
|
||||
website/common/browserify.js
|
||||
Gruntfile.js
|
||||
# Old migrations, disabled
|
||||
migrations/archive/*
|
||||
@@ -6,6 +6,8 @@ services:
|
||||
cache:
|
||||
directories:
|
||||
- 'node_modules'
|
||||
addons:
|
||||
chrome: stable
|
||||
before_install:
|
||||
- npm install -g npm@5
|
||||
before_script:
|
||||
@@ -20,8 +22,10 @@ env:
|
||||
- DISABLE_REQUEST_LOGGING=true
|
||||
matrix:
|
||||
- TEST="lint"
|
||||
- TEST="test:api-v3" REQUIRES_SERVER=true COVERAGE=true
|
||||
- TEST="test:api-v3:unit" REQUIRES_SERVER=true COVERAGE=true
|
||||
- TEST="test:api-v3:integration" REQUIRES_SERVER=true COVERAGE=true
|
||||
- TEST="test:sanity"
|
||||
- TEST="test:content" COVERAGE=true
|
||||
- TEST="test:common" COVERAGE=true
|
||||
- TEST="client:unit" COVERAGE=true
|
||||
- TEST="apidoc"
|
||||
|
||||
@@ -4,7 +4,7 @@ FROM node:boron
|
||||
# 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 mocha
|
||||
RUN npm install -g gulp-cli mocha
|
||||
|
||||
# Clone Habitica repo and install dependencies
|
||||
RUN mkdir -p /usr/src/habitrpg
|
||||
|
||||
@@ -15,12 +15,12 @@ ENV STRIPE_PUB_KEY pk_85fQ0yMECHNfHTSsZoxZXlPSwSNfA
|
||||
# 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 mocha
|
||||
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.23.2 https://github.com/HabitRPG/habitica.git /usr/src/habitrpg
|
||||
RUN git clone --branch v4.29.5 https://github.com/HabitRPG/habitica.git /usr/src/habitrpg
|
||||
RUN npm install
|
||||
RUN gulp build:prod --force
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
Habitica [](https://travis-ci.org/HabitRPG/habitica) [](https://codeclimate.com/github/HabitRPG/habitrpg) [](https://coveralls.io/github/HabitRPG/habitica?branch=develop) [](https://www.bountysource.com/trackers/68393-habitrpg?utm_source=68393&utm_medium=shield&utm_campaign=TRACKER_BADGE)
|
||||
Habitica [](https://travis-ci.org/HabitRPG/habitica) [](https://codeclimate.com/github/HabitRPG/habitrpg) [](https://coveralls.io/github/HabitRPG/habitica?branch=develop) [](https://www.bountysource.com/trackers/68393-habitrpg?utm_source=68393&utm_medium=shield&utm_campaign=TRACKER_BADGE) [](https://www.codetriage.com/habitrpg/habitica)
|
||||
===============
|
||||
|
||||
[](https://greenkeeper.io/)
|
||||
|
||||
[Habitica](https://habitica.com) is an open source habit building program which treats your life like a Role Playing Game. Level up as you succeed, lose HP as you fail, earn money to buy weapons and armor.
|
||||
|
||||
We need more programmers! Your assistance will be greatly appreciated.
|
||||
|
||||
@@ -105,5 +105,12 @@
|
||||
"LOGGLY" : {
|
||||
"TOKEN" : "example-token",
|
||||
"SUBDOMAIN" : "exmaple-subdomain"
|
||||
},
|
||||
"KAFKA": {
|
||||
"GROUP_ID": "",
|
||||
"CLOUDKARAFKA_BROKERS": "",
|
||||
"CLOUDKARAFKA_USERNAME": "",
|
||||
"CLOUDKARAFKA_PASSWORD": "",
|
||||
"CLOUDKARAFKA_TOPIC_PREFIX": ""
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ gulp.task('apidoc:clean', (done) => {
|
||||
clean(APIDOC_DEST_PATH, done);
|
||||
});
|
||||
|
||||
gulp.task('apidoc', ['apidoc:clean'], (done) => {
|
||||
gulp.task('apidoc', gulp.series('apidoc:clean', (done) => {
|
||||
let result = apidoc.createDoc({
|
||||
src: APIDOC_SRC_PATH,
|
||||
dest: APIDOC_DEST_PATH,
|
||||
@@ -19,8 +19,8 @@ gulp.task('apidoc', ['apidoc:clean'], (done) => {
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
gulp.task('apidoc:watch', ['apidoc'], () => {
|
||||
return gulp.watch(`${APIDOC_SRC_PATH}/**/*.js`, ['apidoc']);
|
||||
});
|
||||
gulp.task('apidoc:watch', gulp.series('apidoc', (done) => {
|
||||
return gulp.watch(`${APIDOC_SRC_PATH}/**/*.js`, gulp.series('apidoc', done));
|
||||
}));
|
||||
|
||||
@@ -2,12 +2,6 @@ import gulp from 'gulp';
|
||||
import babel from 'gulp-babel';
|
||||
import webpackProductionBuild from '../webpack/build';
|
||||
|
||||
gulp.task('build', () => {
|
||||
if (process.env.NODE_ENV === 'production') { // eslint-disable-line no-process-env
|
||||
gulp.start('build:prod');
|
||||
}
|
||||
});
|
||||
|
||||
gulp.task('build:src', () => {
|
||||
return gulp.src('website/server/**/*.js')
|
||||
.pipe(babel())
|
||||
@@ -20,18 +14,30 @@ gulp.task('build:common', () => {
|
||||
.pipe(gulp.dest('website/common/transpiled-babel/'));
|
||||
});
|
||||
|
||||
gulp.task('build:server', ['build:src', 'build:common']);
|
||||
gulp.task('build:server', gulp.series('build:src', 'build:common', done => done()));
|
||||
|
||||
// Client Production Build
|
||||
gulp.task('build:client', (done) => {
|
||||
webpackProductionBuild((err, output) => {
|
||||
if (err) return done(err);
|
||||
console.log(output); // eslint-disable-line no-console
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('build:prod', [
|
||||
gulp.task('build:prod', gulp.series(
|
||||
'build:server',
|
||||
'build:client',
|
||||
'apidoc',
|
||||
]);
|
||||
done => done()
|
||||
));
|
||||
|
||||
let buildArgs = [];
|
||||
|
||||
if (process.env.NODE_ENV === 'production') { // eslint-disable-line no-process-env
|
||||
buildArgs.push('build:prod');
|
||||
}
|
||||
|
||||
gulp.task('build', gulp.series(buildArgs, (done) => {
|
||||
done();
|
||||
}));
|
||||
@@ -1,5 +1,4 @@
|
||||
import mongoose from 'mongoose';
|
||||
import autoinc from 'mongoose-id-autoinc';
|
||||
import logger from '../website/server/libs/logger';
|
||||
import nconf from 'nconf';
|
||||
import repl from 'repl';
|
||||
@@ -25,23 +24,23 @@ let improveRepl = (context) => {
|
||||
|
||||
const isProd = nconf.get('NODE_ENV') === 'production';
|
||||
const mongooseOptions = !isProd ? {} : {
|
||||
replset: { socketOptions: { keepAlive: 1, connectTimeoutMS: 30000 } },
|
||||
server: { socketOptions: { keepAlive: 1, connectTimeoutMS: 30000 } },
|
||||
keepAlive: 1,
|
||||
connectTimeoutMS: 30000,
|
||||
useMongoClient: true,
|
||||
};
|
||||
autoinc.init(
|
||||
mongoose.connect(
|
||||
nconf.get('NODE_DB_URI'),
|
||||
mongooseOptions,
|
||||
(err) => {
|
||||
if (err) throw err;
|
||||
logger.info('Connected with Mongoose');
|
||||
}
|
||||
)
|
||||
mongoose.connect(
|
||||
nconf.get('NODE_DB_URI'),
|
||||
mongooseOptions,
|
||||
(err) => {
|
||||
if (err) throw err;
|
||||
logger.info('Connected with Mongoose');
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
gulp.task('console', () => {
|
||||
gulp.task('console', (done) => {
|
||||
improveRepl(repl.start({
|
||||
prompt: 'Habitica > ',
|
||||
}).context);
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -7,6 +7,7 @@ import mergeStream from 'merge-stream';
|
||||
import {basename} from 'path';
|
||||
import {sync} from 'glob';
|
||||
import {each} from 'lodash';
|
||||
import vinylBuffer from 'vinyl-buffer';
|
||||
|
||||
// https://github.com/Ensighten/grunt-spritesmith/issues/67#issuecomment-34786248
|
||||
const MAX_SPRITESHEET_SIZE = 1024 * 1024 * 3;
|
||||
@@ -104,6 +105,7 @@ function createSpritesStream (name, src) {
|
||||
}));
|
||||
|
||||
let imgStream = spriteData.img
|
||||
.pipe(vinylBuffer())
|
||||
.pipe(imagemin())
|
||||
.pipe(gulp.dest(IMG_DIST_PATH));
|
||||
|
||||
@@ -117,8 +119,6 @@ function createSpritesStream (name, src) {
|
||||
return stream;
|
||||
}
|
||||
|
||||
gulp.task('sprites:compile', ['sprites:clean', 'sprites:main', 'sprites:largeSprites', 'sprites:checkCompiledDimensions']);
|
||||
|
||||
gulp.task('sprites:main', () => {
|
||||
let mainSrc = sync('website/raw_sprites/spritesmith/**/*.png');
|
||||
return createSpritesStream('main', mainSrc);
|
||||
@@ -133,7 +133,7 @@ gulp.task('sprites:clean', (done) => {
|
||||
clean(`${IMG_DIST_PATH}spritesmith*,${CSS_DIST_PATH}spritesmith*}`, done);
|
||||
});
|
||||
|
||||
gulp.task('sprites:checkCompiledDimensions', ['sprites:main', 'sprites:largeSprites'], () => {
|
||||
gulp.task('sprites:checkCompiledDimensions', gulp.series('sprites:main', 'sprites:largeSprites', (done) => {
|
||||
console.log('Verifiying that images do not exceed max dimensions'); // eslint-disable-line no-console
|
||||
|
||||
let numberOfSheetsThatAreTooBig = 0;
|
||||
@@ -159,4 +159,7 @@ gulp.task('sprites:checkCompiledDimensions', ['sprites:main', 'sprites:largeSpri
|
||||
} else {
|
||||
console.log('All images are within the correct dimensions'); // eslint-disable-line no-console
|
||||
}
|
||||
});
|
||||
done();
|
||||
}));
|
||||
|
||||
gulp.task('sprites:compile', gulp.series('sprites:clean', 'sprites:main', 'sprites:largeSprites', 'sprites:checkCompiledDimensions', done => done()));
|
||||
|
||||
@@ -3,7 +3,7 @@ import nodemon from 'gulp-nodemon';
|
||||
|
||||
let pkg = require('../package.json');
|
||||
|
||||
gulp.task('nodemon', () => {
|
||||
gulp.task('nodemon', (done) => {
|
||||
nodemon({
|
||||
script: pkg.main,
|
||||
ignore: [
|
||||
@@ -12,4 +12,5 @@ gulp.task('nodemon', () => {
|
||||
'common/dist/script/content/*',
|
||||
],
|
||||
});
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -4,7 +4,6 @@ import {
|
||||
import mongoose from 'mongoose';
|
||||
import { exec } from 'child_process';
|
||||
import gulp from 'gulp';
|
||||
import runSequence from 'run-sequence';
|
||||
import os from 'os';
|
||||
import nconf from 'nconf';
|
||||
|
||||
@@ -39,23 +38,23 @@ let testBin = (string, additionalEnvVariables = '') => {
|
||||
}
|
||||
};
|
||||
|
||||
gulp.task('test:nodemon', () => {
|
||||
gulp.task('test:nodemon', gulp.series(function setupNodemon (done) {
|
||||
process.env.PORT = TEST_SERVER_PORT; // eslint-disable-line no-process-env
|
||||
process.env.NODE_DB_URI = TEST_DB_URI; // eslint-disable-line no-process-env
|
||||
|
||||
runSequence('nodemon');
|
||||
});
|
||||
done();
|
||||
}, 'nodemon'));
|
||||
|
||||
gulp.task('test:prepare:mongo', (cb) => {
|
||||
mongoose.connect(TEST_DB_URI, (err) => {
|
||||
if (err) return cb(`Unable to connect to mongo database. Are you sure it's running? \n\n${err}`);
|
||||
mongoose.connection.db.dropDatabase();
|
||||
mongoose.connection.close();
|
||||
cb();
|
||||
mongoose.connection.dropDatabase((err2) => {
|
||||
if (err2) return cb(err2);
|
||||
mongoose.connection.close(cb);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('test:prepare:server', ['test:prepare:mongo'], () => {
|
||||
gulp.task('test:prepare:server', gulp.series('test:prepare:mongo', (done) => {
|
||||
if (!server) {
|
||||
server = exec(testBin('node ./website/server/index.js', `NODE_DB_URI=${TEST_DB_URI} PORT=${TEST_SERVER_PORT}`), (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
@@ -64,16 +63,18 @@ gulp.task('test:prepare:server', ['test:prepare:mongo'], () => {
|
||||
if (stderr) {
|
||||
console.error(stderr); // eslint-disable-line no-console
|
||||
}
|
||||
done();
|
||||
});
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
gulp.task('test:prepare:build', ['build']);
|
||||
gulp.task('test:prepare:build', gulp.series('build', done => done()));
|
||||
|
||||
gulp.task('test:prepare', [
|
||||
gulp.task('test:prepare', gulp.series(
|
||||
'test:prepare:build',
|
||||
'test:prepare:mongo',
|
||||
]);
|
||||
done => done()
|
||||
));
|
||||
|
||||
gulp.task('test:sanity', (cb) => {
|
||||
let runner = exec(
|
||||
@@ -88,7 +89,7 @@ gulp.task('test:sanity', (cb) => {
|
||||
pipe(runner);
|
||||
});
|
||||
|
||||
gulp.task('test:common', ['test:prepare:build'], (cb) => {
|
||||
gulp.task('test:common', gulp.series('test:prepare:build', (cb) => {
|
||||
let runner = exec(
|
||||
testBin(COMMON_TEST_COMMAND),
|
||||
(err) => {
|
||||
@@ -99,17 +100,17 @@ gulp.task('test:common', ['test:prepare:build'], (cb) => {
|
||||
}
|
||||
);
|
||||
pipe(runner);
|
||||
});
|
||||
}));
|
||||
|
||||
gulp.task('test:common:clean', (cb) => {
|
||||
pipe(exec(testBin(COMMON_TEST_COMMAND), () => cb()));
|
||||
});
|
||||
|
||||
gulp.task('test:common:watch', ['test:common:clean'], () => {
|
||||
gulp.watch(['common/script/**/*', 'test/common/**/*'], ['test:common:clean']);
|
||||
});
|
||||
gulp.task('test:common:watch', gulp.series('test:common:clean', () => {
|
||||
return gulp.watch(['common/script/**/*', 'test/common/**/*'], gulp.series('test:common:clean', done => done()));
|
||||
}));
|
||||
|
||||
gulp.task('test:common:safe', ['test:prepare:build'], (cb) => {
|
||||
gulp.task('test:common:safe', gulp.series('test:prepare:build', (cb) => {
|
||||
let runner = exec(
|
||||
testBin(COMMON_TEST_COMMAND),
|
||||
(err, stdout) => { // eslint-disable-line handle-callback-err
|
||||
@@ -123,9 +124,9 @@ gulp.task('test:common:safe', ['test:prepare:build'], (cb) => {
|
||||
}
|
||||
);
|
||||
pipe(runner);
|
||||
});
|
||||
}));
|
||||
|
||||
gulp.task('test:content', ['test:prepare:build'], (cb) => {
|
||||
gulp.task('test:content', gulp.series('test:prepare:build', (cb) => {
|
||||
let runner = exec(
|
||||
testBin(CONTENT_TEST_COMMAND),
|
||||
CONTENT_OPTIONS,
|
||||
@@ -137,17 +138,17 @@ gulp.task('test:content', ['test:prepare:build'], (cb) => {
|
||||
}
|
||||
);
|
||||
pipe(runner);
|
||||
});
|
||||
}));
|
||||
|
||||
gulp.task('test:content:clean', (cb) => {
|
||||
pipe(exec(testBin(CONTENT_TEST_COMMAND), CONTENT_OPTIONS, () => cb()));
|
||||
});
|
||||
|
||||
gulp.task('test:content:watch', ['test:content:clean'], () => {
|
||||
gulp.watch(['common/script/content/**', 'test/**'], ['test:content:clean']);
|
||||
});
|
||||
gulp.task('test:content:watch', gulp.series('test:content:clean', () => {
|
||||
return gulp.watch(['common/script/content/**', 'test/**'], gulp.series('test:content:clean', done => done()));
|
||||
}));
|
||||
|
||||
gulp.task('test:content:safe', ['test:prepare:build'], (cb) => {
|
||||
gulp.task('test:content:safe', gulp.series('test:prepare:build', (cb) => {
|
||||
let runner = exec(
|
||||
testBin(CONTENT_TEST_COMMAND),
|
||||
CONTENT_OPTIONS,
|
||||
@@ -162,7 +163,7 @@ gulp.task('test:content:safe', ['test:prepare:build'], (cb) => {
|
||||
}
|
||||
);
|
||||
pipe(runner);
|
||||
});
|
||||
}));
|
||||
|
||||
gulp.task('test:api-v3:unit', (done) => {
|
||||
let runner = exec(
|
||||
@@ -179,7 +180,7 @@ gulp.task('test:api-v3:unit', (done) => {
|
||||
});
|
||||
|
||||
gulp.task('test:api-v3:unit:watch', () => {
|
||||
gulp.watch(['website/server/libs/*', 'test/api/v3/unit/**/*', 'website/server/controllers/**/*'], ['test:api-v3:unit']);
|
||||
return gulp.watch(['website/server/libs/*', 'test/api/v3/unit/**/*', 'website/server/controllers/**/*'], gulp.series('test:api-v3:unit', done => done()));
|
||||
});
|
||||
|
||||
gulp.task('test:api-v3:integration', (done) => {
|
||||
@@ -198,8 +199,10 @@ gulp.task('test:api-v3:integration', (done) => {
|
||||
});
|
||||
|
||||
gulp.task('test:api-v3:integration:watch', () => {
|
||||
gulp.watch(['website/server/controllers/api-v3/**/*', 'common/script/ops/*', 'website/server/libs/*.js',
|
||||
'test/api/v3/integration/**/*'], ['test:api-v3:integration']);
|
||||
return gulp.watch([
|
||||
'website/server/controllers/api-v3/**/*', 'common/script/ops/*', 'website/server/libs/*.js',
|
||||
'test/api/v3/integration/**/*',
|
||||
], gulp.series('test:api-v3:integration', done => done()));
|
||||
});
|
||||
|
||||
gulp.task('test:api-v3:integration:separate-server', (done) => {
|
||||
@@ -212,21 +215,17 @@ gulp.task('test:api-v3:integration:separate-server', (done) => {
|
||||
pipe(runner);
|
||||
});
|
||||
|
||||
gulp.task('test', (done) => {
|
||||
runSequence(
|
||||
'test:sanity',
|
||||
'test:content',
|
||||
'test:common',
|
||||
'test:api-v3:unit',
|
||||
'test:api-v3:integration',
|
||||
done
|
||||
);
|
||||
});
|
||||
gulp.task('test', gulp.series(
|
||||
'test:sanity',
|
||||
'test:content',
|
||||
'test:common',
|
||||
'test:api-v3:unit',
|
||||
'test:api-v3:integration',
|
||||
done => done()
|
||||
));
|
||||
|
||||
gulp.task('test:api-v3', (done) => {
|
||||
runSequence(
|
||||
'test:api-v3:unit',
|
||||
'test:api-v3:integration',
|
||||
done
|
||||
);
|
||||
});
|
||||
gulp.task('test:api-v3', gulp.series(
|
||||
'test:api-v3:unit',
|
||||
'test:api-v3:integration',
|
||||
done => done()
|
||||
));
|
||||
|
||||
@@ -93,9 +93,7 @@ const malformedStringExceptions = {
|
||||
feedPet: true,
|
||||
};
|
||||
|
||||
gulp.task('transifex', ['transifex:missingFiles', 'transifex:missingStrings', 'transifex:malformedStrings']);
|
||||
|
||||
gulp.task('transifex:missingFiles', () => {
|
||||
gulp.task('transifex:missingFiles', (done) => {
|
||||
let missingStrings = [];
|
||||
|
||||
eachTranslationFile(ALL_LANGUAGES, (error) => {
|
||||
@@ -109,9 +107,10 @@ gulp.task('transifex:missingFiles', () => {
|
||||
let formattedMessage = formatMessageForPosting(message, missingStrings);
|
||||
postToSlack(formattedMessage, SLACK_CONFIG);
|
||||
}
|
||||
done();
|
||||
});
|
||||
|
||||
gulp.task('transifex:missingStrings', () => {
|
||||
gulp.task('transifex:missingStrings', (done) => {
|
||||
let missingStrings = [];
|
||||
|
||||
eachTranslationString(ALL_LANGUAGES, (language, filename, key, englishString, translationString) => {
|
||||
@@ -126,9 +125,10 @@ gulp.task('transifex:missingStrings', () => {
|
||||
let formattedMessage = formatMessageForPosting(message, missingStrings);
|
||||
postToSlack(formattedMessage, SLACK_CONFIG);
|
||||
}
|
||||
done();
|
||||
});
|
||||
|
||||
gulp.task('transifex:malformedStrings', () => {
|
||||
gulp.task('transifex:malformedStrings', (done) => {
|
||||
let jsonFiles = stripOutNonJsonFiles(fs.readdirSync(ENGLISH_LOCALE));
|
||||
let interpolationRegex = /<%= [a-zA-Z]* %>/g;
|
||||
let stringsToLookFor = getStringsWith(jsonFiles, interpolationRegex);
|
||||
@@ -170,4 +170,11 @@ gulp.task('transifex:malformedStrings', () => {
|
||||
let formattedMessage = formatMessageForPosting(message, stringsWithIncorrectNumberOfInterpolations);
|
||||
postToSlack(formattedMessage, SLACK_CONFIG);
|
||||
}
|
||||
done();
|
||||
});
|
||||
|
||||
gulp.task(
|
||||
'transifex',
|
||||
gulp.series('transifex:missingFiles', 'transifex:missingStrings', 'transifex:malformedStrings'),
|
||||
(done) => done()
|
||||
);
|
||||
@@ -8,10 +8,12 @@
|
||||
|
||||
require('babel-register');
|
||||
|
||||
const gulp = require('gulp');
|
||||
|
||||
if (process.env.NODE_ENV === 'production') { // eslint-disable-line no-process-env
|
||||
require('./gulp/gulp-apidoc'); // eslint-disable-line global-require
|
||||
require('./gulp/gulp-build'); // eslint-disable-line global-require
|
||||
} else {
|
||||
require('glob').sync('./gulp/gulp-*').forEach(require); // eslint-disable-line global-require
|
||||
require('gulp').task('default', ['test']); // eslint-disable-line global-require
|
||||
require('gulp').task('default', gulp.series('test')); // eslint-disable-line global-require
|
||||
}
|
||||
|
||||
7
migrations/.eslintrc
Normal file
7
migrations/.eslintrc
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"root": false,
|
||||
"rules": {
|
||||
"no-console": 0,
|
||||
"no-use-before-define": ["error", { "functions": false }]
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
db.users.update(
|
||||
{ lastCron: { $exists: false} },
|
||||
{ $set: { lastCron: +new Date } },
|
||||
{ multi: true }
|
||||
);
|
||||
@@ -1,15 +0,0 @@
|
||||
db.users.find({ completedIds: { $exists: true } }).forEach(function(user) {
|
||||
var newTodoIds = user.todoIds;
|
||||
user.completedIds.forEach(function(value) {
|
||||
if (newTodoIds.indexOf(value) === -1) {
|
||||
newTodoIds.push(value)
|
||||
}
|
||||
});
|
||||
db.users.update(
|
||||
{ _id: user._id },
|
||||
{
|
||||
$set: { todoIds: newTodoIds },
|
||||
$unset: { completedIds: 1 }
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -1,5 +0,0 @@
|
||||
db.users.update(
|
||||
{preferences:{$exists:false}},
|
||||
{$set:{preferences:{gender: 'm', armorSet: 'v1'}}},
|
||||
{multi:true}
|
||||
)
|
||||
@@ -1,102 +0,0 @@
|
||||
// %mongo server:27017/dbname underscore.js my_commands.js
|
||||
// %mongo server:27017/dbname underscore.js --shell
|
||||
|
||||
//db.users.find({'auth.facebook.email': 'tylerrenelle@gmail.com'}).forEach(function(user){
|
||||
db.users.find().forEach(function(user){
|
||||
|
||||
if (!user._id) {
|
||||
print("User has null _id");
|
||||
return; // need to figure out how to delete these buggers if they don't have an id to delete from
|
||||
}
|
||||
|
||||
if (!!user.idLists) {
|
||||
print("User " + user._id + " has already been migrated")
|
||||
return
|
||||
}
|
||||
|
||||
if (user._id.indexOf("$") === 0) {
|
||||
print("User id starts with $ (" + user._id + ")")
|
||||
return;
|
||||
}
|
||||
|
||||
// even though we're clobbering user later, sometimes these are undefined and crash the script
|
||||
// this saves us some ternaries
|
||||
user.stats = user.stats || {};
|
||||
user.items = user.items || {};
|
||||
user.preferences = user.preferences || {};
|
||||
user.notifications = user.notifications || {};
|
||||
user.flags = user.flags || {};
|
||||
user.habitIds = user.habitIds || [];
|
||||
user.dailyIds = user.dailyIds || [];
|
||||
user.todoIds = user.todoIds || [];
|
||||
user.rewardIds = user.rewardIds|| [];
|
||||
|
||||
_.each(user.tasks, function(task, key){
|
||||
if (!task.type) {
|
||||
delete user.tasks[key];
|
||||
// idList will take care of itself on page-load
|
||||
return
|
||||
}
|
||||
if (key == '$spec') {
|
||||
print("$spec was found: " + user._id);
|
||||
return
|
||||
}
|
||||
if (key.indexOf("$_") === 0) {
|
||||
var newKey = key.replace("$_", ''),
|
||||
index = user[task.type + "Ids"].indexOf(key)
|
||||
user[task.type + "Ids"][index] = newKey;
|
||||
task.id = newKey
|
||||
user.tasks[newKey] = task
|
||||
// TODO make sure this is ok, that we're not deleting the original
|
||||
// Otherwise use lodash.cloneDeep
|
||||
delete user.tasks[key]
|
||||
}
|
||||
});
|
||||
|
||||
// New user schema has public and private paths, so we can setup proper access control with racer
|
||||
// Note 'public' and 'private' are reserved words
|
||||
var newUser = {
|
||||
auth: user.auth, // we need this top-level due to derby-auth
|
||||
apiToken: user.preferences.api_token || null, // set on update, we need derby.uuid()
|
||||
preferences: {
|
||||
armorSet: user.preferences.armorSet || 'v1',
|
||||
gender: user.preferences.gender || 'm'
|
||||
},
|
||||
balance: user.balance || 2,
|
||||
lastCron: user.lastCron || +new Date,
|
||||
history: user.history || [],
|
||||
stats: {
|
||||
gp: user.stats.money || 0,
|
||||
hp: user.stats.hp || 50,
|
||||
exp: user.stats.exp || 0,
|
||||
lvl: user.stats.lvl || 1
|
||||
},
|
||||
items: {
|
||||
armor: user.items.armor || 0,
|
||||
weapon: user.items.weapon || 0
|
||||
},
|
||||
tasks: user.tasks || {},
|
||||
idLists: {
|
||||
habit: user.habitIds || [],
|
||||
daily: user.dailyIds || [],
|
||||
todo: user.todoIds || [],
|
||||
reward: user.rewardIds || []
|
||||
},
|
||||
flags: {
|
||||
partyEnabled: false,
|
||||
itemsEnabled: user.items.itemsEnabled || false,
|
||||
kickstarter: user.notifications.kickstarter || 'show',
|
||||
ads: user.flags.ads || null // null because it's set on registration
|
||||
},
|
||||
party: {
|
||||
current: null,
|
||||
invitation: null
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
db.users.update({_id:user._id}, newUser);
|
||||
} catch(e) {
|
||||
print(e);
|
||||
}
|
||||
})
|
||||
@@ -1,19 +0,0 @@
|
||||
// move idList back to root-level, is what's causing the sort bug - see https://github.com/codeparty/racer/pull/73
|
||||
|
||||
// We could just delete user.idLists, since it's re-created on refresh. However, users's first refresh will scare them
|
||||
// since everything will dissappear - second refresh will bring everything back.
|
||||
db.users.find().forEach(function(user){
|
||||
if (!user.idLists) return;
|
||||
db.users.update(
|
||||
{_id:user._id},
|
||||
{
|
||||
$set:{
|
||||
'habitIds':user.idLists.habit,
|
||||
'dailyIds':user.idLists.daily,
|
||||
'todoIds':user.idLists.todo,
|
||||
'rewardIds':user.idLists.reward
|
||||
}
|
||||
//$unset:{idLists:true} // run this after the code has been pushed
|
||||
}
|
||||
)
|
||||
})
|
||||
@@ -1,20 +0,0 @@
|
||||
db.users.update(
|
||||
{items:{$exists:0}},
|
||||
{$set:{items:{weapon: 0, armor: 0, head: 0, shield: 0 }}},
|
||||
{multi:true}
|
||||
);
|
||||
|
||||
db.users.find().forEach(function(user){
|
||||
|
||||
var updates = {
|
||||
// I'm not racist, these were just the defaults before ;)
|
||||
'preferences.skin': 'white',
|
||||
'preferences.hair': 'blond',
|
||||
|
||||
'items.head': user.items.armor,
|
||||
'items.shield': user.items.armor,
|
||||
}
|
||||
|
||||
db.users.update({_id:user._id}, {$set:updates});
|
||||
|
||||
})
|
||||
@@ -1,39 +0,0 @@
|
||||
// mongo habitrpg ./node_modules/underscore/underscore.js ./migrations/20130307_normalize_algo_values.js
|
||||
|
||||
/**
|
||||
* Make sure people aren't overflowing their exp with the new system
|
||||
*/
|
||||
db.users.find().forEach(function(user){
|
||||
function oldTnl(level) {
|
||||
return (Math.pow(level,2)*10)+(level*10)+80
|
||||
}
|
||||
|
||||
function newTnl(level) {
|
||||
var value = 0;
|
||||
if (level >= 100) {
|
||||
value = 0
|
||||
} else {
|
||||
value = Math.round(((Math.pow(level,2)*0.25)+(10 * level) + 139.75)/10)*10; // round to nearest 10
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
var newTnl = newTnl(user.stats.lvl);
|
||||
if (user.stats.exp > newTnl) {
|
||||
var percent = user.stats.exp / oldTnl(user.stats.lvl);
|
||||
percent = (percent>1) ? 1 : percent;
|
||||
user.stats.exp = newTnl * percent;
|
||||
|
||||
try {
|
||||
db.users.update(
|
||||
{_id:user._id},
|
||||
{$set: {'stats.exp': user.stats.exp}},
|
||||
{multi:true}
|
||||
);
|
||||
} catch(e) {
|
||||
print(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
@@ -1,47 +0,0 @@
|
||||
// mongo habitrpg ./node_modules/underscore/underscore.js ./migrations/20130307_normalize_algo_values.js
|
||||
|
||||
/**
|
||||
* Users were experiencing a lot of extreme Exp multiplication (https://github.com/lefnire/habitrpg/issues/594).
|
||||
* This sets things straight, and in preparation for another algorithm overhaul
|
||||
*/
|
||||
db.users.find().forEach(function(user){
|
||||
if (user.stats.exp >= 3580) {
|
||||
user.stats.exp = 0;
|
||||
}
|
||||
|
||||
if (user.stats.lvl > 100) {
|
||||
user.stats.lvl = 100;
|
||||
}
|
||||
|
||||
_.each(user.tasks, function(task, key){
|
||||
// remove corrupt tasks
|
||||
if (!task) {
|
||||
delete user.tasks[key];
|
||||
return;
|
||||
}
|
||||
|
||||
// Fix busted values
|
||||
if (task.value > 21.27) {
|
||||
task.value = 21.27;
|
||||
}
|
||||
else if (task.value < -47.27) {
|
||||
task.value = -47.27;
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
db.users.update(
|
||||
{_id:user._id},
|
||||
{$set:
|
||||
{
|
||||
'stats.lvl': user.stats.lvl,
|
||||
'stats.exp': user.stats.exp,
|
||||
'tasks' : user.tasks
|
||||
}
|
||||
},
|
||||
{multi:true}
|
||||
);
|
||||
} catch(e) {
|
||||
print(e);
|
||||
}
|
||||
})
|
||||
@@ -1,28 +0,0 @@
|
||||
/**
|
||||
* Remove duff histories for dailies
|
||||
*/
|
||||
// mongo habitrpg ./node_modules/underscore/underscore.js ./migrations/20130307_remove_duff_histories.js
|
||||
db.users.find().forEach(function(user){
|
||||
|
||||
|
||||
_.each(user.tasks, function(task, key){
|
||||
if (task.type === "daily") {
|
||||
// remove busted history entries
|
||||
task.history = _.filter(task.history, function(h){return !!h.value})
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
db.users.update(
|
||||
{_id:user._id},
|
||||
{$set:
|
||||
{
|
||||
'tasks' : user.tasks
|
||||
}
|
||||
},
|
||||
{multi:true}
|
||||
);
|
||||
} catch(e) {
|
||||
print(e);
|
||||
}
|
||||
})
|
||||
@@ -1,98 +0,0 @@
|
||||
/**
|
||||
* Migrate old pets to new system
|
||||
*/
|
||||
// mongo habitrpg ./node_modules/underscore/underscore.js ./migrations/20130326_migrate_pets.js
|
||||
|
||||
// IMPORTANT NOTE: this migration was written when we were using version 3 of lodash.
|
||||
// We've now upgraded to lodash v4 but the code used in this migration has not been
|
||||
// adapted to work with it. Before this migration is used again any lodash method should
|
||||
// be checked for compatibility against the v4 changelog and changed if necessary.
|
||||
// https://github.com/lodash/lodash/wiki/Changelog#v400
|
||||
|
||||
var mapping = {
|
||||
bearcub: {name:'BearCub', modifier: 'Base'},
|
||||
cactus: {name:'Cactus', modifier:'Base'},
|
||||
dragon: {name:'Dragon', modifier:'Base'},
|
||||
flyingpig: {name:'FlyingPig', modifier:'Base'},
|
||||
fox: {name:'Fox', modifier:'Base'},
|
||||
lioncub: {name:'LionCub', modifier:'Base'},
|
||||
pandacub: {name:'PandaCub', modifier:'Base'},
|
||||
tigercub: {name:'TigerCub', modifier:'Base'},
|
||||
wolfBorder: {name:'Wolf', modifier:'Base'},
|
||||
wolfDesert: {name:'Wolf', modifier:'Desert'},
|
||||
wolfGolden: {name:'Wolf', modifier:'Golden'},
|
||||
wolfRed: {name:'Wolf', modifier:'Red'},
|
||||
wolfShade: {name:'Wolf', modifier:'Shade'},
|
||||
wolfSkeleton: {name:'Wolf', modifier:'Skeleton'},
|
||||
wolfVeteran: {name:'Wolf', modifier:'Veteran'},
|
||||
wolfWhite: {name:'Wolf', modifier:'White'},
|
||||
wolfZombie: {name:'Wolf', modifier:'Zombie'}
|
||||
}
|
||||
|
||||
/**
|
||||
== Old Style ==
|
||||
pet: Object
|
||||
icon: "Pet-Wolf-White.png"
|
||||
index: 14
|
||||
name: "wolfWhite"
|
||||
text: "White Wolf"
|
||||
value: 3
|
||||
pets: Object
|
||||
bearcub: true
|
||||
cactus: true
|
||||
|
||||
== New Style ==
|
||||
currentPet: Object
|
||||
modifier: "Red"
|
||||
name: "Wolf"
|
||||
notes: "Find some Hatching Powder to sprinkle on this egg, and one day it will hatch into a loyal pet."
|
||||
str: "Wolf-Red"
|
||||
text: "Wolf"
|
||||
value: 3
|
||||
pets: Array
|
||||
0: "PandaCub-Base"
|
||||
1: "Wolf-Base"
|
||||
*/
|
||||
|
||||
|
||||
db.users.find().forEach(function(user){
|
||||
if (!user.items || (!user.items.pets && !user.items.pet)) return;
|
||||
|
||||
// migrate items.pet to items.currentPet
|
||||
if (!!user.items.pet) {
|
||||
var mapped = mapping[user.items.pet.name];
|
||||
delete user.items.pet;
|
||||
user.items.currentPet = {
|
||||
modifier: mapped.modifier,
|
||||
name: mapped.name,
|
||||
str: mapped.name + "-" + mapped.modifier,
|
||||
text: '' // FIXME?
|
||||
}
|
||||
}
|
||||
|
||||
// migrate items.pets
|
||||
if (!!user.items.pets) {
|
||||
var newPets = [];
|
||||
_.each(user.items.pets, function(val, key){
|
||||
if (_.isNumber(key)) {
|
||||
newPets.push(val)
|
||||
//FIXME why is this happening? seems the user gets migrated already...
|
||||
//throw "Error: User appears already migrated, this shouldn't be happening!"
|
||||
} else {
|
||||
newPets.push(mapping[key].name + "-" + mapping[key].modifier);
|
||||
}
|
||||
});
|
||||
user.items.pets = newPets;
|
||||
}
|
||||
|
||||
try {
|
||||
db.users.update(
|
||||
{_id:user._id},
|
||||
{$set:
|
||||
{ 'items' : user.items }
|
||||
}
|
||||
);
|
||||
} catch(e) {
|
||||
print(e);
|
||||
}
|
||||
})
|
||||
@@ -1,110 +0,0 @@
|
||||
/**
|
||||
* Applies backer tokens & items (this file will be updated periodically
|
||||
*/
|
||||
|
||||
// mongo habitrpg ./node_modules/underscore/underscore.js migrations/20130327_apply_tokens.js
|
||||
|
||||
// IMPORTANT NOTE: this migration was written when we were using version 3 of lodash.
|
||||
// We've now upgraded to lodash v4 but the code used in this migration has not been
|
||||
// adapted to work with it. Before this migration is used again any lodash method should
|
||||
// be checked for compatibility against the v4 changelog and changed if necessary.
|
||||
// https://github.com/lodash/lodash/wiki/Changelog#v400
|
||||
|
||||
var mapping = [
|
||||
{
|
||||
tier: 1,
|
||||
tokens: 0,
|
||||
users: []
|
||||
},
|
||||
{
|
||||
tier: 5,
|
||||
tokens: 20,
|
||||
users: []
|
||||
},
|
||||
{
|
||||
tier: 10,
|
||||
tokens: 50,
|
||||
users: []
|
||||
},
|
||||
{
|
||||
tier: 15,
|
||||
tokens: 100,
|
||||
users: []
|
||||
},
|
||||
{
|
||||
tier: 30,
|
||||
tokens: 150,
|
||||
users: []
|
||||
},
|
||||
{
|
||||
tier: 45,
|
||||
tokens: 170,
|
||||
users: []
|
||||
},
|
||||
{
|
||||
tier: 60,
|
||||
tokens: 200,
|
||||
users: []
|
||||
},
|
||||
{
|
||||
tier: 70,
|
||||
tokens: 240,
|
||||
users: []
|
||||
},
|
||||
{
|
||||
tier: 80,
|
||||
tokens: 240,
|
||||
users: []
|
||||
},
|
||||
{
|
||||
tier: 90,
|
||||
tokens: 280,
|
||||
users: []
|
||||
},
|
||||
{
|
||||
tier: 300,
|
||||
tokens: 500,
|
||||
users: []
|
||||
},
|
||||
{
|
||||
tier: 800,
|
||||
tokens: 500,
|
||||
users: []
|
||||
}
|
||||
];
|
||||
|
||||
db.users.find().forEach(function(user){
|
||||
if (!user._id) return;
|
||||
|
||||
var possibleUserIds = [user._id];
|
||||
if (!!user.local) {
|
||||
if (!!user.local.username) possibleUserIds.push(user.local.username);
|
||||
if (!!user.local.email) possibleUserIds.push(user.local.email);
|
||||
}
|
||||
|
||||
_.each(mapping, function(tier){
|
||||
var userInTier = !_.isEmpty(_.intersection(tier.users, possibleUserIds));
|
||||
if (userInTier) {
|
||||
var tokenInc = 0,
|
||||
backer = user.backer || {};
|
||||
if (!backer.tokensApplied) {
|
||||
tokenInc = tier.tokens;
|
||||
backer.tokensApplied = true;
|
||||
}
|
||||
backer.tier = tier.tier;
|
||||
|
||||
try {
|
||||
db.users.update(
|
||||
{_id:user._id},
|
||||
{
|
||||
$set: { backer: backer, 'flags.ads': 'hide' },
|
||||
$inc: { balance: (tokenInc/4) }
|
||||
}
|
||||
);
|
||||
} catch(e) {
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
@@ -1,22 +0,0 @@
|
||||
/**
|
||||
* For users who already have max gear, they earned the achievement
|
||||
*/
|
||||
// mongo habitrpg ./node_modules/underscore/underscore.js ./migrations/20130503_max_gear_achievement.js
|
||||
db.users.find().forEach(function(user){
|
||||
var items = user.items;
|
||||
if (!items) { return; }
|
||||
if ( parseInt(items.armor) == 5 &&
|
||||
parseInt(items.head) == 5 &&
|
||||
parseInt(items.shield) == 5 &&
|
||||
parseInt(items.weapon) == 6) {
|
||||
|
||||
try {
|
||||
db.users.update(
|
||||
{_id:user._id},
|
||||
{$set: {'achievements.ultimateGear':true}}
|
||||
);
|
||||
} catch(e) {
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -1 +0,0 @@
|
||||
db.users.update({'backer.tier':{$gte:80}}, {$push:{'items.pets':'Wolf-Cerberus'}}, {multi:true});
|
||||
@@ -1,31 +0,0 @@
|
||||
//mongo habitrpg ./node_modules/lodash/lodash.js migrations/20130602_survey_rewards.js
|
||||
|
||||
// IMPORTANT NOTE: this migration was written when we were using version 3 of lodash.
|
||||
// We've now upgraded to lodash v4 but the code used in this migration has not been
|
||||
// adapted to work with it. Before this migration is used again any lodash method should
|
||||
// be checked for compatibility against the v4 changelog and changed if necessary.
|
||||
// https://github.com/lodash/lodash/wiki/Changelog#v400
|
||||
|
||||
var members = []
|
||||
members = _.uniq(members);
|
||||
|
||||
var query = {
|
||||
_id: {$exists:1},
|
||||
$or:[
|
||||
{_id: {$in: members}},
|
||||
//{'profile.name': {$in: members}},
|
||||
{'auth.facebook.name': {$in: members}},
|
||||
{'auth.local.username': {$in: members}},
|
||||
{'auth.local.email': {$in: members}}
|
||||
]
|
||||
};
|
||||
|
||||
print(db.users.count(query));
|
||||
|
||||
db.users.update(query,
|
||||
{
|
||||
$set: { 'achievements.helpedHabit': true },
|
||||
$inc: { balance: 2.5 }
|
||||
},
|
||||
{multi:true}
|
||||
)
|
||||
@@ -1,9 +0,0 @@
|
||||
//mongo habitrpg migrations/20130612_survey_rewards_individual.js
|
||||
|
||||
var query = {_id: ""};
|
||||
|
||||
db.users.update(query,
|
||||
{
|
||||
$set: { 'achievements.helpedHabit': true },
|
||||
$inc: { balance: 2.5 }
|
||||
})
|
||||
@@ -1,4 +0,0 @@
|
||||
db.users.ensureIndex( { _id: 1, apiToken: 1 }, {background: true} )
|
||||
db.groups.ensureIndex( { members: 1 }, {background: true} )
|
||||
db.groups.ensureIndex( { type: 1 }, {background: true} )
|
||||
db.groups.ensureIndex( { type: 1, privacy: 1 }, {background: true} )
|
||||
@@ -1,16 +0,0 @@
|
||||
//mongo habitrpg ./node_modules/lodash/lodash.js migrations/20130908_cleanup_corrupt_tags.js
|
||||
|
||||
// Racer was notorious for adding duplicates, randomly deleting documents, etc. Once we pull the plug on old.habit,
|
||||
// run this migration to cleanup all the corruption
|
||||
|
||||
db.users.find().forEach(function(user){
|
||||
user.tags = _.filter(user.tags, (function(t) {
|
||||
return !!t ? t.id : false;
|
||||
}));
|
||||
|
||||
try {
|
||||
db.users.update({_id:user._id}, {$set:{tags:user.tags}});
|
||||
} catch(e) {
|
||||
print(e);
|
||||
}
|
||||
})
|
||||
@@ -1,5 +0,0 @@
|
||||
db.users.find().forEach(function(user){
|
||||
if (!user.purchased) user.purchased = {hair: {}, skin: {}};
|
||||
user.purchased.ads = user.flags && !!user.flags.ads;
|
||||
db.users.update({_id:user._id}, {$set:{'purchased': user.purchased, 'flags.newStuff': true}, $unset: {'flags.ads':1}});
|
||||
});
|
||||
@@ -1,12 +0,0 @@
|
||||
// node .migrations/20131022_restore_ads.js
|
||||
var mongo = require('mongoskin');
|
||||
var _ = require('lodash');
|
||||
var dbBackup = mongo.db('localhost:27017/habitrpg?auto_reconnect');
|
||||
var dbLive = mongo.db('localhost:27017/habitrpg2?auto_reconnect');
|
||||
var count = 89474;
|
||||
dbBackup.collection('users').findEach({$or: [{'flags.ads':'show'}, {'flags.ads': null}]}, {batchSize:10}, function(err, item) {
|
||||
if (err) return console.error({err:err});
|
||||
if (!item || !item._id) return console.error('blank user');
|
||||
dbLive.collection('users').update({_id:item._id}, {$set:{'purchased.ads':false}, $unset: {'flags.ads': 1}});
|
||||
if (--count <= 0) console.log("DONE!");
|
||||
});
|
||||
@@ -1,25 +0,0 @@
|
||||
// mongo habitrpg ./node_modules/lodash/lodash.js ./migrations/20131028_task_subdocs_tags_invites.js
|
||||
|
||||
db.challenges.find().forEach(function(chal){
|
||||
_.each(chal.habits.concat(chal.dailys).concat(chal.todos).concat(chal.rewards), function(task){
|
||||
task.id = task.id || task._id;
|
||||
})
|
||||
try {
|
||||
db.challenges.update({_id:chal._id}, chal);
|
||||
db.groups.update({_id:chal.group}, {$addToSet:{challenges:chal._id}})
|
||||
} catch(e) {
|
||||
print(e);
|
||||
}
|
||||
});
|
||||
|
||||
db.users.find().forEach(function(user){
|
||||
_.each(user.habits.concat(user.dailys).concat(user.todos).concat(user.rewards), function(task){
|
||||
task.id = task.id || task._id;
|
||||
})
|
||||
try {
|
||||
db.users.update({_id:user._id}, user);
|
||||
} catch(e) {
|
||||
print(e);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
db.users.find({},{todos:1}).forEach(function(user){
|
||||
_.each(user.todos, function(task){
|
||||
if (moment(task.date).toDate() == 'Invalid Date')
|
||||
task.date = moment().format('MM/DD/YYYY');
|
||||
})
|
||||
db.users.update({_id:user._id}, {$set:{todos: user.todos}});
|
||||
});
|
||||
@@ -1,21 +0,0 @@
|
||||
function deleteId(h){
|
||||
delete h._id;
|
||||
}
|
||||
|
||||
db.users.find({},{habits:1,dailys:1,history:1}).forEach(function(user){
|
||||
if (user.history) {
|
||||
_.each(['todos','exp'], function(type){
|
||||
if (user.history[type]) {
|
||||
_.each(user.history.exp, deleteId);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
user.history = {exp:[],todos:[]};
|
||||
}
|
||||
|
||||
_.each(['habits', 'dailys'], function(type){
|
||||
_.each(user[type].history, deleteId);
|
||||
});
|
||||
|
||||
db.users.update({_id:user._id}, {$set:{history: user.history, habits: user.habits, dailys: user.dailys}});
|
||||
});
|
||||
@@ -1,4 +0,0 @@
|
||||
// Increase everyone's gems per their contribution level
|
||||
db.users.find({'contributor.level':{$gt:0}},{contributor:1, balance:1}).forEach(function(user){
|
||||
db.users.update({_id:user._id}, {$inc: {balance: (user.contributor.level * .5)} });
|
||||
});
|
||||
@@ -1,15 +0,0 @@
|
||||
// This migration has already been run in the past. It's vital to fix these users presently, but we need to find
|
||||
// out why task values are ever getting in as NaN. My guess is API PUT /tasks/:tid routes
|
||||
db.users.find({},{habits:1,dailys:1,todos:1,rewards:1}).forEach(function(user){
|
||||
_.each(['habits','dailys','todos','rewards'], function(type){
|
||||
_.each(user[type], function(task){
|
||||
task.value = +task.value;
|
||||
if (_.isNaN(task.value)) {
|
||||
task.value = 0;
|
||||
print(user._id);
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
db.users.update({_id:user._id}, {$set:{habits: user.habits, dailys: user.dailys, todos: user.todos, rewards: user.rewards}});
|
||||
});
|
||||
@@ -1,14 +0,0 @@
|
||||
// Migrate all users websites to the profile blurb field
|
||||
db.users.find({'profile.websites':{$exists: true}}).forEach(function(user){
|
||||
db.users.update({_id: user._id}, {
|
||||
$set: {"profile.blurb": user.profile.blurb + '\n * ' + user.profile.websites.join('\n * ')},
|
||||
$unset: {'profile.websites': 1}
|
||||
})
|
||||
})
|
||||
|
||||
db.groups.find({'websites.0':{$exists: true}}).forEach(function(group){
|
||||
db.groups.update({_id: group._id}, {
|
||||
$set: {"description": group.description + '\n * ' + group.websites.join('\n * ')},
|
||||
$unset: {websites: 1}
|
||||
})
|
||||
})
|
||||
@@ -1,10 +0,0 @@
|
||||
//Add defaults to show gears in all users
|
||||
db.users.update(
|
||||
{},
|
||||
{$set:{
|
||||
'preferences.showWeapon': true,
|
||||
'preferences.showShield': true,
|
||||
'preferences.showArmor': true,
|
||||
}},
|
||||
{multi:true}
|
||||
)
|
||||
@@ -1,18 +0,0 @@
|
||||
// TODO figure out why this is happening in the first place
|
||||
|
||||
db.users.find({},{habits:1, dailys:1, todos:1, rewards:1}).forEach(function(user){
|
||||
_.each(user.habits, function(task){
|
||||
task.type = 'habit';
|
||||
})
|
||||
_.each(user.dailys, function(task){
|
||||
task.type = 'daily';
|
||||
})
|
||||
_.each(user.todos, function(task){
|
||||
task.type = 'todo';
|
||||
})
|
||||
_.each(user.rewards, function(task){
|
||||
task.type = 'reward';
|
||||
})
|
||||
|
||||
db.users.update({_id:user._id}, {$set:{habits: user.habits, dailys: user.dailys, todos: user.todos, rewards: user.rewards}});
|
||||
});
|
||||
@@ -1,12 +0,0 @@
|
||||
// once and for all!
|
||||
|
||||
db.users.find({'items.pets':{$exists:1}},{'items.pets':1}).forEach(function(user){
|
||||
_.reduce(user.items.pets, function(m,v,k){
|
||||
if (!k.indexOf('undefined')) m.push(k);
|
||||
return m;
|
||||
}, []).forEach(function(key){
|
||||
delete user.items.pets[key];
|
||||
})
|
||||
|
||||
db.users.update({_id:user._id}, { $set:{'items.pets':user.items.pets} });
|
||||
});
|
||||
@@ -1,13 +0,0 @@
|
||||
// Cleanup broken tags
|
||||
// -------------------------
|
||||
db.users.find().forEach(function(user){
|
||||
var tasks = user.habits.concat(user.dailys).concat(user.todos).concat(user.rewards);
|
||||
|
||||
_.each(tasks, function(task){
|
||||
_.each(task.tags, function(value, key){ //value is true, key is tag.id
|
||||
if (!_.find(user.tags,{id:key})) delete task.tags[key];
|
||||
});
|
||||
});
|
||||
|
||||
db.users.update({_id:user._id}, user);
|
||||
});
|
||||
@@ -1,8 +0,0 @@
|
||||
//Add default to randomize party members list
|
||||
db.users.update(
|
||||
{},
|
||||
{$set:{
|
||||
'party.order': 'random',
|
||||
}},
|
||||
{multi:true}
|
||||
)
|
||||
@@ -1,5 +0,0 @@
|
||||
db.users.find({'preferences.dayStart':{$exists:1}},{'preferences.dayStart':1}).forEach(function(user){
|
||||
var dayStart = +user.preferences.dayStart;
|
||||
dayStart = (_.isNaN(dayStart) || dayStart < 0 || dayStart > 24) ? 0 : dayStart;
|
||||
db.users.update({_id:user._id}, {$set:{'preferences.dayStart':dayStart}});
|
||||
});
|
||||
@@ -1 +0,0 @@
|
||||
db.users.update({},{$set:{'items.pets.Turkey-Base':5, 'flags.newStuff':true}}, {multi:true});
|
||||
@@ -1,38 +0,0 @@
|
||||
// node .migrations/20131127_restore_dayStart.js
|
||||
|
||||
// IMPORTANT NOTE: this migration was written when we were using version 3 of lodash.
|
||||
// We've now upgraded to lodash v4 but the code used in this migration has not been
|
||||
// adapted to work with it. Before this migration is used again any lodash method should
|
||||
// be checked for compatibility against the v4 changelog and changed if necessary.
|
||||
// https://github.com/lodash/lodash/wiki/Changelog#v400
|
||||
|
||||
var mongo = require('mongoskin');
|
||||
var _ = require('lodash');
|
||||
|
||||
var backupUsers = mongo.db('localhost:27017/habitrpg_old?auto_reconnect').collection('users');
|
||||
var liveUsers = mongo.db('localhost:27017/habitrpg_new?auto_reconnect').collection('users');
|
||||
|
||||
var query = {'preferences.dayStart':{$exists:1,$ne:0}};
|
||||
var select = {'preferences.dayStart': 1};
|
||||
|
||||
backupUsers.count(query, function(err, count){
|
||||
if (err) return console.error(err);
|
||||
backupUsers.findEach(query, select, {batchSize:20}, function(err, before){
|
||||
if (err) return console.error(err);
|
||||
if (!before) { count--; return console.log('!before'); }
|
||||
liveUsers.findById(before._id, function(err, after){
|
||||
if (err) return console.error(err);
|
||||
if (!after) { count--; return console.log(before._id + ' deleted?'); }
|
||||
|
||||
var dayStart = +before.preferences.dayStart;
|
||||
if (after.preferences.dayStart == 0 && dayStart != 0){
|
||||
dayStart = (_.isNaN(dayStart) || dayStart < 0 || dayStart > 24) ? 0 : dayStart;
|
||||
} else {
|
||||
dayStart = after.preferences.dayStart;
|
||||
}
|
||||
|
||||
liveUsers.update({_id:after._id}, {$inc:{_v:1}, $set:{'preferences.dayStart':dayStart}});
|
||||
if (--count <= 0) console.log("DONE!");
|
||||
})
|
||||
});
|
||||
});
|
||||
@@ -1,51 +0,0 @@
|
||||
// node .migrations/20131221_restore_NaN_history.js
|
||||
|
||||
// IMPORTANT NOTE: this migration was written when we were using version 3 of lodash.
|
||||
// We've now upgraded to lodash v4 but the code used in this migration has not been
|
||||
// adapted to work with it. Before this migration is used again any lodash method should
|
||||
// be checked for compatibility against the v4 changelog and changed if necessary.
|
||||
// https://github.com/lodash/lodash/wiki/Changelog#v400
|
||||
|
||||
/**
|
||||
* After the classes migration, users lost some history entries
|
||||
*/
|
||||
var mongo = require('mongoskin');
|
||||
var _ = require('lodash');
|
||||
|
||||
var backupUsers = mongo.db('localhost:27017/habitrpg_old?auto_reconnect').collection('users');
|
||||
var liveUsers = mongo.db('localhost:27017/habitrpg?auto_reconnect').collection('users');
|
||||
|
||||
function filterNaNs(h) {
|
||||
return h && _.isNumber(+h.value) && !_.isNaN(+h.value);
|
||||
}
|
||||
|
||||
var fields = {history:1,habits:1,dailys:1,migration:1};
|
||||
var count = 0;
|
||||
liveUsers.findEach({migration: {$ne:'20131221_restore_NaN_history'}}, fields, {batchSize:500}, function(err, after){
|
||||
if (!after) err = '!after';
|
||||
if (err) {count++;return console.error(err);}
|
||||
|
||||
backupUsers.findById(after._id, fields, function(err, before){
|
||||
if (err) {count++;return console.error(err);}
|
||||
|
||||
_.each(['todos','exp'],function(type){
|
||||
if (!_.isEmpty(after.history[type]))
|
||||
after.history[type] = _.filter(after.history[type], filterNaNs);
|
||||
if (before && !_.isEmpty(before.history[type]))
|
||||
after.history[type] = before.history[type].concat(after.history[type]);
|
||||
})
|
||||
|
||||
_.each(['habits','dailys'], function(type){
|
||||
_.each(after[type], function(t){
|
||||
t.history = _.filter(t.history, filterNaNs);
|
||||
var found = before && _.find(before[type],{id:t.id});
|
||||
if (found && found.history) t.history = found.history.concat(t.history);
|
||||
})
|
||||
})
|
||||
|
||||
liveUsers.update({_id:after._id}, {$set:{history:after.history, dailys:after.dailys, habits:after.habits, migration:'20131221_restore_NaN_history'}, $inc:{_v:1}});
|
||||
//if (--count <= 0) console.log("DONE! " + after._id);
|
||||
if (++count%1000 == 0) console.log(count);
|
||||
if (after._id == '9') console.log('lefnire processed');
|
||||
})
|
||||
});
|
||||
@@ -1,38 +0,0 @@
|
||||
// node .migrations/20131225_restore_streaks.js
|
||||
|
||||
// IMPORTANT NOTE: this migration was written when we were using version 3 of lodash.
|
||||
// We've now upgraded to lodash v4 but the code used in this migration has not been
|
||||
// adapted to work with it. Before this migration is used again any lodash method should
|
||||
// be checked for compatibility against the v4 changelog and changed if necessary.
|
||||
// https://github.com/lodash/lodash/wiki/Changelog#v400
|
||||
|
||||
/**
|
||||
* After the classes migration, users lost some history entries
|
||||
*/
|
||||
var mongo = require('mongoskin');
|
||||
var _ = require('lodash');
|
||||
|
||||
var backupUsers = mongo.db('localhost:27017/habitrpg_old?auto_reconnect').collection('users');
|
||||
var liveUsers = mongo.db('lefnire:mAdn3s5s@charlotte.mongohq.com:10015/habitrpg_large?auto_reconnect').collection('users');
|
||||
|
||||
var fields = {dailys:1,migration:1};
|
||||
var count = 0;
|
||||
liveUsers.findEach({migration: {$ne:'20131225_restore_streaks'}}, fields, {batchSize:250}, function(err, after){
|
||||
if (!after) err = '!after';
|
||||
if (err) {count++;return console.error(err);}
|
||||
|
||||
backupUsers.findById(after._id, fields, function(err, before){
|
||||
if (!before) err = '!before';
|
||||
if (err) {count++;return console.error(err);}
|
||||
|
||||
_.each(before.dailys,function(d){
|
||||
var found = _.find(after.dailys,{id: d.id});
|
||||
if (found && !found.streak) found.streak = d.streak;
|
||||
})
|
||||
|
||||
liveUsers.update({_id:after._id}, {$set:{dailys:after.dailys, migration:'20131225_restore_streaks'}, $inc:{_v:1}});
|
||||
//if (--count <= 0) console.log("DONE! " + after._id);
|
||||
if (++count%1000 == 0) console.log(count);
|
||||
if (after._id == '9') console.log('lefnire processed');
|
||||
})
|
||||
});
|
||||
@@ -1,8 +0,0 @@
|
||||
db.users.find({},{todos:1,dailys:1,rewards:1,habits:1}).forEach(function(user){
|
||||
_.each(user.habits.concat(user.dailys).concat(user.todos).concat(user.rewards), function(t){
|
||||
t.dateCreated = t.created || new Date;
|
||||
delete t.created;
|
||||
if (t.type == 'todo' && t.completed) t.dateCompleted = new Date;
|
||||
})
|
||||
db.users.update({_id:user._id}, {$set:{habits:user.habits,dailys:user.dailys,todos:user.todos,rewards:user.rewards}});
|
||||
});
|
||||
@@ -1 +0,0 @@
|
||||
db.users.update({},{$set:{'achievements.habitBirthday':true}},{multi:1})
|
||||
@@ -1,12 +0,0 @@
|
||||
db.users.update({},{$set:{
|
||||
'items.food.Cake_Skeleton':1,
|
||||
'items.food.Cake_Base':1,
|
||||
'items.food.Cake_CottonCandyBlue':1,
|
||||
'items.food.Cake_CottonCandyPink':1,
|
||||
'items.food.Cake_Shade':1,
|
||||
'items.food.Cake_White':1,
|
||||
'items.food.Cake_Golden':1,
|
||||
'items.food.Cake_Zombie':1,
|
||||
'items.food.Cake_Desert':1,
|
||||
'items.food.Cake_Red':1
|
||||
}},{multi:1})
|
||||
@@ -1,3 +0,0 @@
|
||||
db.challenges.find({},{members:1}).forEach(function(chal){
|
||||
db.challenges.update({_id:chal._id}, {$set:{memberCount:chal.members.length}});
|
||||
});
|
||||
@@ -1,14 +0,0 @@
|
||||
db.users.update(
|
||||
{
|
||||
'purchased.plan.dateCreated':{$gte:new Date('2014-02-22'),$lt:new Date('2014-02-29')},
|
||||
'items.gear.owned.armor_mystery_201402':null,
|
||||
'items.gear.owned.head_mystery_201402': null,
|
||||
'items.gear.owned.back_mystery_201402': null,
|
||||
'purchased.plan.mysteryItems':{$nin:['armor_mystery_201402','head_mystery_201402','back_mystery_201402']}
|
||||
},
|
||||
//{_id:1,'purchased.plan':1,'items.gear.owned':1}
|
||||
{$push: {'purchased.plan.mysteryItems':{$each:['armor_mystery_201402','head_mystery_201402','back_mystery_201402']}}},
|
||||
{multi:true}
|
||||
)/*.forEach(function(user){
|
||||
printjson(user);
|
||||
});*/
|
||||
@@ -1 +0,0 @@
|
||||
db.users.update({'backer.tier':{$gt:69}},{$set:{'items.mounts.LionCub-Ethereal':true}},{multi:1})
|
||||
@@ -1,11 +0,0 @@
|
||||
//mongo habitrpg node_modules/lodash/lodash.js ./migrations/20140712_wiped_quest_membership.js
|
||||
db.groups.find({type:'party','quest.key':{$ne:null},'quest.active':true},{quest:1}).forEach(function(group){
|
||||
var activeMembers = _.reduce(group.quest.members, function(m,v,k){
|
||||
if (v===true) m.push(k); return m;
|
||||
},[]);
|
||||
db.users.update(
|
||||
{_id:{$in: activeMembers}},
|
||||
{$set:{'party.quest.key':group.quest.key,'party.quest.completed':null}},
|
||||
{multi:true}
|
||||
);
|
||||
});
|
||||
@@ -1,13 +0,0 @@
|
||||
var _ = require('lodash');
|
||||
|
||||
db.users.find({}).forEach(function(user){
|
||||
var newNewMessages = {};
|
||||
|
||||
_.each(user.newMessages, function(val, key){
|
||||
if(key != "undefined"){
|
||||
newNewMessages[key] = val;
|
||||
};
|
||||
});
|
||||
|
||||
db.users.update({_id: user._id}, {$set: {'newMessages': newNewMessages}});
|
||||
});
|
||||
@@ -1,81 +0,0 @@
|
||||
// node .migrations/20140829_change_headAccessory_to_eyewear.js
|
||||
|
||||
var migrationName = '20140829_change_headAccessory_to_eyewear';
|
||||
var authorName = 'Alys'; // in case script author needs to know when their ...
|
||||
var authorUuid = 'd904bd62-da08-416b-a816-ba797c9ee265'; //... own data is done
|
||||
|
||||
// IMPORTANT NOTE: this migration was written when we were using version 3 of lodash.
|
||||
// We've now upgraded to lodash v4 but the code used in this migration has not been
|
||||
// adapted to work with it. Before this migration is used again any lodash method should
|
||||
// be checked for compatibility against the v4 changelog and changed if necessary.
|
||||
// https://github.com/lodash/lodash/wiki/Changelog#v400
|
||||
|
||||
/**
|
||||
* https://github.com/HabitRPG/habitrpg/issues/3645
|
||||
*/
|
||||
var mongo = require('mongoskin');
|
||||
var _ = require('lodash');
|
||||
var liveUsers = mongo.db('localhost:27017/habitrpg2?auto_reconnect').collection('users');
|
||||
|
||||
var fields = {'migration':1,
|
||||
'items.gear.costume.headAccessory':1,
|
||||
'items.gear.equipped.headAccessory':1,
|
||||
'items.gear.owned.headAccessory_special_wondercon_black':1,
|
||||
'items.gear.owned.headAccessory_special_wondercon_red':1,
|
||||
'items.gear.owned.headAccessory_special_summerRogue':1,
|
||||
'items.gear.owned.headAccessory_special_summerWarrior':1
|
||||
};
|
||||
|
||||
var progressCount = 1000;
|
||||
var count = 0;
|
||||
liveUsers.findEach({ $and: [
|
||||
{ migration: {$ne:migrationName} },
|
||||
{ $or: [
|
||||
{'items.gear.owned.headAccessory_special_summerRogue': {'$exists':true}},
|
||||
{'items.gear.owned.headAccessory_special_summerWarrior':{'$exists':true}},
|
||||
{'items.gear.owned.headAccessory_special_wondercon_red':{'$exists':true}},
|
||||
{'items.gear.owned.headAccessory_special_wondercon_black':{'$exists':true}}
|
||||
]}
|
||||
]}, fields, {batchSize:250}, function(err, user){
|
||||
count++;
|
||||
if (!user) err = '!user';
|
||||
if (err) {return console.error(err);}
|
||||
|
||||
var set = {'migration': migrationName};
|
||||
var unset = {};
|
||||
|
||||
var oldToNew = {
|
||||
'headAccessory_special_summerRogue': 'eyewear_special_summerRogue',
|
||||
'headAccessory_special_summerWarrior': 'eyewear_special_summerWarrior',
|
||||
'headAccessory_special_wondercon_red': 'eyewear_special_wondercon_red',
|
||||
'headAccessory_special_wondercon_black':'eyewear_special_wondercon_black'
|
||||
};
|
||||
|
||||
// items.gear.costume, items.gear.equipped:
|
||||
_.each(['costume','equipped'],function(type){
|
||||
_.each(oldToNew,function(newName,oldName){
|
||||
if (user.items.gear[type].headAccessory === oldName) {
|
||||
unset['items.gear.'+type+'.headAccessory'] = "";
|
||||
set['items.gear.'+type+'.eyewear'] = newName;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// items.gear.owned:
|
||||
_.each(oldToNew,function(newName,oldName){
|
||||
if (oldName in user.items.gear.owned) {
|
||||
unset['items.gear.owned.'+oldName] = "";
|
||||
set['items.gear.owned.'+newName] = user.items.gear.owned[oldName];
|
||||
}
|
||||
});
|
||||
|
||||
//console.log(JSON.stringify(user, null, " "));
|
||||
//console.log("set: " + JSON.stringify(set, null, " "));
|
||||
//console.log("unset: " + JSON.stringify(unset, null, " "));
|
||||
|
||||
liveUsers.update({_id:user._id}, {$set:set, $unset:unset, $inc:{_v:1}});
|
||||
|
||||
if (count%progressCount == 0) console.log(count + ' ' + user._id);
|
||||
if (user._id == '9') console.log('lefnire processed');
|
||||
if (user._id == authorUuid) console.log(authorName + ' processed');
|
||||
});
|
||||
@@ -1,131 +0,0 @@
|
||||
// IMPORTANT:
|
||||
//
|
||||
// run like this to capture all output:
|
||||
//
|
||||
// node 20140831_increase_gems_for_previous_contributions.js > 20140831_increase_gems_for_previous_contributions_output.txt
|
||||
|
||||
// IMPORTANT NOTE: this migration was written when we were using version 3 of lodash.
|
||||
// We've now upgraded to lodash v4 but the code used in this migration has not been
|
||||
// adapted to work with it. Before this migration is used again any lodash method should
|
||||
// be checked for compatibility against the v4 changelog and changed if necessary.
|
||||
// https://github.com/lodash/lodash/wiki/Changelog#v400
|
||||
|
||||
var migrationName = '20140831_increase_gems_for_previous_contributions';
|
||||
|
||||
/**
|
||||
* https://github.com/HabitRPG/habitrpg/issues/3933
|
||||
* Increase Number of Gems for Contributors
|
||||
* author: Alys (d904bd62-da08-416b-a816-ba797c9ee265)
|
||||
*
|
||||
* Increase everyone's gems per their contribution level.
|
||||
* Originally they were given 2 gems per tier.
|
||||
* Now they are given 3 gems per tier for tiers 1,2,3
|
||||
* and 4 gems per tier for tiers 4,5,6,7
|
||||
* So that means an EXTRA 1 for tier 1,
|
||||
* 2 for tier 2,
|
||||
* 3 for tier 3,
|
||||
* 5 for tier 4,
|
||||
* 7 for tier 5,
|
||||
* 9 for tier 6,
|
||||
* 11 for tier 7,
|
||||
* 11 for tier 8 (moderators = tier 7 + admin privileges),
|
||||
* none for tier 9 (staff)
|
||||
*/
|
||||
|
||||
var mongo = require('mongoskin');
|
||||
var _ = require('lodash');
|
||||
|
||||
|
||||
var dbUsers = mongo.db('localhost:27017/habitrpg?auto_reconnect').collection('users');
|
||||
|
||||
|
||||
var query = {
|
||||
'contributor.level': {$gt: 0, $lt: 9},
|
||||
'migration': {$ne: migrationName}
|
||||
};
|
||||
|
||||
var fields = {
|
||||
'migration':1,
|
||||
'contributor.level':1,
|
||||
'balance':1
|
||||
};
|
||||
|
||||
var userResults = {}; // each key is a UUID, each value is a string
|
||||
// describing what changed for that user
|
||||
|
||||
console.warn('Updating users...');
|
||||
var progressCount = 50;
|
||||
var count = 0;
|
||||
dbUsers.findEach(query, fields, function(err, user) {
|
||||
if (err) { return exiting(1, 'ERROR! ' + err); }
|
||||
if (!user) {
|
||||
console.warn('All users found. Fetching final balances...');
|
||||
return fetchFinalBalances();
|
||||
}
|
||||
count++;
|
||||
|
||||
var set = {'migration': migrationName};
|
||||
|
||||
var tier = user.contributor.level;
|
||||
var extraGems = tier; // tiers 1,2,3
|
||||
if (tier > 3) { extraGems = 3 + (tier - 3) * 2; }
|
||||
if (tier == 8) { extraGems = 11; }
|
||||
var extraBalance = extraGems / 4;
|
||||
set['balance'] = user.balance + extraBalance;
|
||||
|
||||
// Capture current state of user:
|
||||
userResults[user._id] =
|
||||
user._id + ' ' + ':\n' +
|
||||
' contrib tier : ' + tier + '\n' +
|
||||
' balance before : ' + user.balance + '\n' +
|
||||
' balance (gems) added : ' + extraBalance + ' (' +
|
||||
extraGems + ')' + '\n' +
|
||||
' expected balance after: ' + (user.balance + extraBalance) + '\n';
|
||||
|
||||
// Update user:
|
||||
dbUsers.update({_id:user._id}, {$set:set, $inc:{_v:1}});
|
||||
if (count%progressCount == 0) console.warn(count + ' ' + user._id);
|
||||
});
|
||||
|
||||
|
||||
function fetchFinalBalances() {
|
||||
var query = {_id: {$in: Object.keys(userResults)}};
|
||||
var fields = {
|
||||
'balance':1,
|
||||
};
|
||||
|
||||
var count1 = 0;
|
||||
dbUsers.findEach(query, fields, function(err, user) {
|
||||
if (err) { return exiting(1, 'ERROR! ' + err); }
|
||||
if (!user) {
|
||||
console.warn('All final balances found.');
|
||||
return displayData();
|
||||
}
|
||||
count1++;
|
||||
userResults[user._id] = userResults[user._id] +
|
||||
user._id + ' ' + ':\n' +
|
||||
' actual balance after : ' + user.balance + '\n';
|
||||
if (count1%progressCount == 0) console.warn(count1 + ' ' + user._id);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function displayData() {
|
||||
_.each(userResults, function(text, uuid) {
|
||||
console.log(text); // text contains uuid
|
||||
});
|
||||
console.log('\n' + count +
|
||||
' users processed (should be roughly 335 according to the Hall)\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);
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
var migrationName = '20140914_upgrade_admin_contrib_tiers';
|
||||
var authorName = 'Alys'; // in case script author needs to know when their ...
|
||||
var authorUuid = 'd904bd62-da08-416b-a816-ba797c9ee265'; //... own data is done
|
||||
|
||||
/**
|
||||
* https://github.com/HabitRPG/habitrpg/issues/3801
|
||||
* Convert Tier 8 contributors to Tier 9 (staff) (all current Tier 8s are admins).
|
||||
* Convert Tier 7 contributors with admin flag to Tier 8 (moderators).
|
||||
*/
|
||||
|
||||
// IMPORTANT NOTE: this migration was written when we were using version 3 of lodash.
|
||||
// We've now upgraded to lodash v4 but the code used in this migration has not been
|
||||
// adapted to work with it. Before this migration is used again any lodash method should
|
||||
// be checked for compatibility against the v4 changelog and changed if necessary.
|
||||
// https://github.com/lodash/lodash/wiki/Changelog#v400
|
||||
|
||||
var mongo = require('mongoskin');
|
||||
var _ = require('lodash');
|
||||
|
||||
var dbUsers = mongo.db('localhost:27017/habitrpg?auto_reconnect').collection('users');
|
||||
|
||||
var query =
|
||||
{ 'contributor.level':{$gte:7}, 'contributor.admin':true, 'migration': {$ne: migrationName} };
|
||||
|
||||
var fields = {'migration':1,
|
||||
'contributor.admin':1,
|
||||
'contributor.level':1,
|
||||
'auth.local.username':1,
|
||||
'profile.name':1,
|
||||
};
|
||||
|
||||
var userResults = {}; // each key is a UUID, each value is a username;
|
||||
// contains only the users changed
|
||||
|
||||
console.warn('Updating users...');
|
||||
var progressCount = 1000;
|
||||
var count = 0;
|
||||
dbUsers.findEach(query, fields, {batchSize:250}, function(err, user) {
|
||||
if (err) { return exiting(1, 'ERROR! ' + err); }
|
||||
if (!user) {
|
||||
console.warn('All appropriate users found and modified.');
|
||||
return displayData();
|
||||
}
|
||||
count++;
|
||||
|
||||
var set = {'migration': migrationName};
|
||||
var inc = {'contributor.level':1, _v:1};
|
||||
|
||||
userResults[user._id] = user.profile.name;
|
||||
|
||||
dbUsers.update({_id:user._id}, {$set:set, $inc:inc});
|
||||
|
||||
if (count%progressCount == 0) console.warn(count + ' ' + user._id);
|
||||
if (user._id == authorUuid) console.warn(authorName + ' processed');
|
||||
if (user._id == '9' ) console.warn('lefnire' + ' processed');
|
||||
});
|
||||
|
||||
|
||||
function displayData() {
|
||||
console.log('users modified:');
|
||||
_.each(userResults, function(name, uuid) {
|
||||
console.log(name);
|
||||
});
|
||||
console.warn('\n' + count +
|
||||
' users processed (should be 11 according to the Hall)\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);
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
db.users.update(
|
||||
{},
|
||||
{
|
||||
$inc: {
|
||||
'items.food.Candy_Base':1,
|
||||
'items.food.Candy_CottonCandyBlue':1,
|
||||
'items.food.Candy_CottonCandyPink':1,
|
||||
'items.food.Candy_Desert':1,
|
||||
'items.food.Candy_Golden':1,
|
||||
'items.food.Candy_Red':1,
|
||||
'items.food.Candy_Shade':1,
|
||||
'items.food.Candy_Skeleton':1,
|
||||
'items.food.Candy_White':1,
|
||||
'items.food.Candy_Zombie':1
|
||||
}
|
||||
},
|
||||
{multi:1}
|
||||
);
|
||||
@@ -1 +0,0 @@
|
||||
db.users.update({_id:'9'},{$set:{'items.pets.JackOLantern-Base':5, 'flags.newStuff':true}}, {multi:true});
|
||||
@@ -1,11 +0,0 @@
|
||||
db.users.update(
|
||||
{'items.pets.Turkey-Base':{$ne:null}},
|
||||
{$set:{'items.mounts.Turkey-Base':true}},
|
||||
{multi:1}
|
||||
)
|
||||
|
||||
db.users.update(
|
||||
{'items.pets.Turkey-Base':null},
|
||||
{$set:{'items.pets.Turkey-Base':5}},
|
||||
{multi:1}
|
||||
)
|
||||
@@ -1,4 +0,0 @@
|
||||
db.users.update({'purchased.plan.consecutive.count':NaN}, {$set:{'purchased.plan.consecutive.count':0}}, {multi:1});
|
||||
db.users.update({'purchased.plan.consecutive.offset':NaN}, {$set:{'purchased.plan.consecutive.offset':0}}, {multi:1});
|
||||
db.users.update({'purchased.plan.consecutive.gemCapExtra':NaN}, {$set:{'purchased.plan.consecutive.gemCapExtra':0}}, {multi:1});
|
||||
db.users.update({'purchased.plan.consecutive.trinkets':NaN}, {$set:{'purchased.plan.consecutive.trinkets':0}}, {multi:1});
|
||||
@@ -1,11 +0,0 @@
|
||||
db.users.update(
|
||||
{'items.gear.owned.head_special_nye':{$ne:null}},
|
||||
{$set:{'items.gear.owned.head_special_nye2014':false}},
|
||||
{multi:1}
|
||||
)
|
||||
|
||||
db.users.update(
|
||||
{'items.gear.owned.head_special_nye':null},
|
||||
{$set:{'items.gear.owned.head_special_nye':false}},
|
||||
{multi:1}
|
||||
)
|
||||
@@ -1,8 +0,0 @@
|
||||
db.users.update(
|
||||
{'purchased.plan.customerId':{$ne:null}, 'purchased.plan.dateUpdated':null},
|
||||
{
|
||||
$set: {'purchased.plan.dateUpdated': new Date('12/01/2014')},
|
||||
$unset: {'purchased.plan.datedUpdated':''}
|
||||
},
|
||||
{multi:true}
|
||||
);
|
||||
@@ -1,88 +0,0 @@
|
||||
var migrationName = '20150124_mountmaster_fix.js';
|
||||
var authorName = 'Alys'; // in case script author needs to know when their ...
|
||||
var authorUuid = 'd904bd62-da08-416b-a816-ba797c9ee265'; //... own data is done
|
||||
|
||||
/**
|
||||
* https://github.com/HabitRPG/habitrpg/pull/4374#issuecomment-71038795
|
||||
* Convert false to null for mounts that used to be owned.
|
||||
*/
|
||||
|
||||
var dbserver = 'localhost:27017' // CHANGE THIS FOR PRODUCTION DATABASE
|
||||
|
||||
// IMPORTANT NOTE: this migration was written when we were using version 3 of lodash.
|
||||
// We've now upgraded to lodash v4 but the code used in this migration has not been
|
||||
// adapted to work with it. Before this migration is used again any lodash method should
|
||||
// be checked for compatibility against the v4 changelog and changed if necessary.
|
||||
// https://github.com/lodash/lodash/wiki/Changelog#v400
|
||||
|
||||
var mongo = require('mongoskin');
|
||||
var _ = require('lodash');
|
||||
|
||||
var dbUsers = mongo.db(dbserver + '/habitrpg?auto_reconnect').collection('users');
|
||||
|
||||
var query = {
|
||||
'items.mounts':{$exists:true}
|
||||
};
|
||||
|
||||
var fields = {
|
||||
'items.mounts':1
|
||||
};
|
||||
|
||||
var animals = [ "Wolf-Base", "Wolf-White", "Wolf-Desert", "Wolf-Red", "Wolf-Shade", "Wolf-Skeleton", "Wolf-Zombie", "Wolf-CottonCandyPink", "Wolf-CottonCandyBlue", "Wolf-Golden", "TigerCub-Base", "TigerCub-White", "TigerCub-Desert", "TigerCub-Red", "TigerCub-Shade", "TigerCub-Skeleton", "TigerCub-Zombie", "TigerCub-CottonCandyPink", "TigerCub-CottonCandyBlue", "TigerCub-Golden", "PandaCub-Base", "PandaCub-White", "PandaCub-Desert", "PandaCub-Red", "PandaCub-Shade", "PandaCub-Skeleton", "PandaCub-Zombie", "PandaCub-CottonCandyPink", "PandaCub-CottonCandyBlue", "PandaCub-Golden", "LionCub-Base", "LionCub-White", "LionCub-Desert", "LionCub-Red", "LionCub-Shade", "LionCub-Skeleton", "LionCub-Zombie", "LionCub-CottonCandyPink", "LionCub-CottonCandyBlue", "LionCub-Golden", "Fox-Base", "Fox-White", "Fox-Desert", "Fox-Red", "Fox-Shade", "Fox-Skeleton", "Fox-Zombie", "Fox-CottonCandyPink", "Fox-CottonCandyBlue", "Fox-Golden", "FlyingPig-Base", "FlyingPig-White", "FlyingPig-Desert", "FlyingPig-Red", "FlyingPig-Shade", "FlyingPig-Skeleton", "FlyingPig-Zombie", "FlyingPig-CottonCandyPink", "FlyingPig-CottonCandyBlue", "FlyingPig-Golden", "Dragon-Base", "Dragon-White", "Dragon-Desert", "Dragon-Red", "Dragon-Shade", "Dragon-Skeleton", "Dragon-Zombie", "Dragon-CottonCandyPink", "Dragon-CottonCandyBlue", "Dragon-Golden", "Cactus-Base", "Cactus-White", "Cactus-Desert", "Cactus-Red", "Cactus-Shade", "Cactus-Skeleton", "Cactus-Zombie", "Cactus-CottonCandyPink", "Cactus-CottonCandyBlue", "Cactus-Golden", "BearCub-Base", "BearCub-White", "BearCub-Desert", "BearCub-Red", "BearCub-Shade", "BearCub-Skeleton", "BearCub-Zombie", "BearCub-CottonCandyPink", "BearCub-CottonCandyBlue", "BearCub-Golden" ]; // all Gen1 mounts
|
||||
|
||||
console.warn('Updating users...');
|
||||
var progressCount = 1000;
|
||||
var count = 0;
|
||||
dbUsers.findEach(query, fields, {batchSize:250}, function(err, user) {
|
||||
if (err) { return exiting(1, 'ERROR! ' + err); }
|
||||
if (!user) {
|
||||
console.warn('All appropriate users found and modified.');
|
||||
return displayData();
|
||||
}
|
||||
count++;
|
||||
|
||||
var mounts = user.items.mounts;
|
||||
var changed = false;
|
||||
for(var a in animals) {
|
||||
if(mounts[animals[a]] == false) {
|
||||
mounts[animals[a]] = null;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
dbUsers.update(
|
||||
{ _id: user._id},
|
||||
{
|
||||
$set: { "migration": migrationName,
|
||||
"items.mounts" : mounts
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// var set = {'migration': migrationName};
|
||||
// var inc = {'xyz':1, _v:1};
|
||||
// dbUsers.update({_id:user._id}, {$set:set, $inc:inc});
|
||||
|
||||
if (count%progressCount == 0) console.warn(count + ' ' + user._id);
|
||||
if (user._id == authorUuid) console.warn(authorName + ' processed');
|
||||
if (user._id == '9' ) console.warn('lefnire' + ' 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);
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
db.users.update(
|
||||
{'items.gear.owned.armor_special_birthday':{$ne:null}},
|
||||
{$set:{'items.gear.owned.armor_special_birthday2015':false}},
|
||||
{multi:1}
|
||||
)
|
||||
|
||||
db.users.update(
|
||||
{'items.gear.owned.armor_special_birthday':null},
|
||||
{$set:{'items.gear.owned.armor_special_birthday':false}},
|
||||
{multi:1}
|
||||
)
|
||||
|
||||
db.users.update({},{$inc:{
|
||||
'items.food.Cake_Skeleton':1,
|
||||
'items.food.Cake_Base':1,
|
||||
'items.food.Cake_CottonCandyBlue':1,
|
||||
'items.food.Cake_CottonCandyPink':1,
|
||||
'items.food.Cake_Shade':1,
|
||||
'items.food.Cake_White':1,
|
||||
'items.food.Cake_Golden':1,
|
||||
'items.food.Cake_Zombie':1,
|
||||
'items.food.Cake_Desert':1,
|
||||
'items.food.Cake_Red':1
|
||||
}},{multi:1})
|
||||
|
||||
db.users.update(
|
||||
{'achievements.habitBirthday':true},
|
||||
{$set:{'achievements.habitBirthdays':1}},
|
||||
{multi:1}
|
||||
)
|
||||
|
||||
db.users.update(
|
||||
{},
|
||||
{$inc:{'achievements.habitBirthdays':1}},
|
||||
{multi:1}
|
||||
)
|
||||
@@ -1,78 +0,0 @@
|
||||
var migrationName = '20150131_birthday_goodies_fix__one_birthday__1';
|
||||
var authorName = 'Alys'; // in case script author needs to know when their ...
|
||||
var authorUuid = 'd904bd62-da08-416b-a816-ba797c9ee265'; //... own data is done
|
||||
|
||||
/*
|
||||
* remove new birthday robes and second achievement from people who shouldn't have them
|
||||
*/
|
||||
|
||||
var dbserver = 'localhost:27017' // CHANGE THIS FOR PRODUCTION DATABASE
|
||||
|
||||
// IMPORTANT NOTE: this migration was written when we were using version 3 of lodash.
|
||||
// We've now upgraded to lodash v4 but the code used in this migration has not been
|
||||
// adapted to work with it. Before this migration is used again any lodash method should
|
||||
// be checked for compatibility against the v4 changelog and changed if necessary.
|
||||
// https://github.com/lodash/lodash/wiki/Changelog#v400
|
||||
|
||||
var mongo = require('mongoskin');
|
||||
var _ = require('lodash');
|
||||
|
||||
var dbUsers = mongo.db(dbserver + '/habitrpg?auto_reconnect').collection('users');
|
||||
|
||||
// 'auth.timestamps.created':{$gt:new Date('2014-02-01')},
|
||||
var query = {
|
||||
'achievements.habitBirthdays':1,
|
||||
'auth.timestamps.loggedin':{$gt:new Date('2014-12-20')}
|
||||
};
|
||||
|
||||
// '_id': 'c03e41bd-501f-438c-9553-a7afdf52a08c',
|
||||
// 'achievements.habitBirthday':{$exists:false},
|
||||
// 'items.gear.owned.armor_special_birthday2015':1
|
||||
|
||||
var fields = {
|
||||
// 'auth.timestamps.created':1,
|
||||
// 'achievements.habitBirthday':1,
|
||||
// 'achievements.habitBirthdays':1,
|
||||
'items.gear.owned.armor_special_birthday2015':1,
|
||||
// 'items.gear.owned.armor_special':1
|
||||
};
|
||||
|
||||
console.warn('Updating users...');
|
||||
var progressCount = 1000;
|
||||
var count = 0;
|
||||
dbUsers.findEach(query, fields, {batchSize:250}, function(err, user) {
|
||||
if (err) { return exiting(1, 'ERROR! ' + err); }
|
||||
if (!user) {
|
||||
console.warn('All appropriate users found and modified.');
|
||||
return displayData();
|
||||
}
|
||||
count++;
|
||||
|
||||
var unset = {'items.gear.owned.armor_special_birthday2015': 1};
|
||||
// var set = {'migration':migrationName, 'achievements.habitBirthdays':1 };
|
||||
// var inc = {'xyz':1, _v:1};
|
||||
dbUsers.update({_id:user._id}, {$unset:unset}); // , $inc:inc});
|
||||
// dbUsers.update({_id:user._id}, {$unset:unset, $set:set});
|
||||
// console.warn(user.auth.timestamps.created);
|
||||
|
||||
if (count%progressCount == 0) console.warn(count + ' ' + user._id);
|
||||
if (user._id == authorUuid) console.warn(authorName + ' processed');
|
||||
if (user._id == '9' ) console.warn('lefnire' + ' 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);
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
var migrationName = '20150201_convert_creation_date_from_string_to_object__no_date_recent_signup';
|
||||
//// var migrationName = '20150201_convert_creation_date_from_string_to_object';
|
||||
|
||||
var authorName = 'Alys'; // in case script author needs to know when their ...
|
||||
var authorUuid = 'd904bd62-da08-416b-a816-ba797c9ee265'; //... own data is done
|
||||
|
||||
/*
|
||||
* For users that have no value for auth.timestamps.created, assign them
|
||||
* a recent value.
|
||||
*
|
||||
* NOTE:
|
||||
* Before this script was used as described above, it was first used to
|
||||
* find all users that have a auth.timestamps.created field that is a string
|
||||
* rather than a date object and set it to be a date object. The code used
|
||||
* for this has been commented out with four slashes: ////
|
||||
*
|
||||
* https://github.com/HabitRPG/habitrpg/issues/4601#issuecomment-72339846
|
||||
*/
|
||||
|
||||
var dbserver = 'localhost:27017' // CHANGE THIS FOR PRODUCTION DATABASE
|
||||
|
||||
// IMPORTANT NOTE: this migration was written when we were using version 3 of lodash.
|
||||
// We've now upgraded to lodash v4 but the code used in this migration has not been
|
||||
// adapted to work with it. Before this migration is used again any lodash method should
|
||||
// be checked for compatibility against the v4 changelog and changed if necessary.
|
||||
// https://github.com/lodash/lodash/wiki/Changelog#v400
|
||||
|
||||
var mongo = require('mongoskin');
|
||||
var _ = require('lodash');
|
||||
var moment = require('moment');
|
||||
|
||||
var dbUsers = mongo.db(dbserver + '/habitrpg?auto_reconnect').collection('users');
|
||||
|
||||
var uuidArrayRecent=[ // recent users with no creation dates
|
||||
'1a0d4b75-73ed-4937-974d-d504d6398884',
|
||||
'1c7ebe27-1250-4f95-ba10-965580adbfd7',
|
||||
'5f972121-4a6d-411c-95e9-7093d3e89b66',
|
||||
'ae85818a-e336-4ccd-945e-c15cef975102',
|
||||
'ba273976-d9fc-466c-975f-38559d34a824',
|
||||
];
|
||||
|
||||
var query = {
|
||||
'_id':{$in: uuidArrayRecent}
|
||||
//// 'auth':{$exists:true},
|
||||
//// 'auth.timestamps':{$exists:true},
|
||||
//// 'auth.timestamps.created':{$not: {$lt:new Date('2018-01-01')}}
|
||||
};
|
||||
|
||||
var fields = {
|
||||
'_id':1,
|
||||
'auth.timestamps.created':1
|
||||
};
|
||||
// 'achievements.habitBirthdays':1
|
||||
|
||||
console.warn('Updating users...');
|
||||
var progressCount = 1000;
|
||||
var count = 0;
|
||||
dbUsers.findEach(query, fields, {batchSize:250}, function(err, user) {
|
||||
if (err) { return exiting(1, 'ERROR! ' + err); }
|
||||
if (!user) {
|
||||
console.warn('All appropriate users found and modified.');
|
||||
return displayData();
|
||||
}
|
||||
count++;
|
||||
|
||||
//// var oldDate = user.auth.timestamps.created;
|
||||
//// var newDate = moment(oldDate).toDate();
|
||||
var oldDate = 'none';
|
||||
var newDate = moment('2015-01-11').toDate();
|
||||
console.warn(user._id + ' == ' + oldDate + ' == ' + newDate);
|
||||
|
||||
//// var set = { 'migration': migrationName,
|
||||
//// 'auth.timestamps.created': newDate,
|
||||
//// 'achievements.habitBirthdays': 2,
|
||||
//// 'items.gear.owned.head_special_nye':true,
|
||||
//// 'items.gear.owned.head_special_nye2014':true,
|
||||
//// 'items.gear.owned.armor_special_birthday':true,
|
||||
//// 'items.gear.owned.armor_special_birthday2015':true,
|
||||
//// };
|
||||
|
||||
var set = { 'migration': migrationName,
|
||||
'auth.timestamps.created': newDate,
|
||||
'achievements.habitBirthdays': 1,
|
||||
'items.gear.owned.armor_special_birthday':true,
|
||||
};
|
||||
|
||||
// var unset = {'items.gear.owned.armor_special_birthday2015': 1};
|
||||
// var inc = {'xyz':1, _v:1};
|
||||
dbUsers.update({_id:user._id}, {$set:set});
|
||||
// dbUsers.update({_id:user._id}, {$unset:unset, $set:set, $inc:inc});
|
||||
|
||||
if (count%progressCount == 0) console.warn(count + ' ' + user._id);
|
||||
if (user._id == authorUuid) console.warn(authorName + ' processed');
|
||||
if (user._id == '9' ) console.warn('lefnire' + ' 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);
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
db.users.update({
|
||||
'flags.recaptureEmailsPhase': {
|
||||
$gt: 0
|
||||
}
|
||||
},{$inc:{
|
||||
'flags.recaptureEmailsPhase':1
|
||||
}},{multi:1})
|
||||
@@ -1,10 +0,0 @@
|
||||
db.users.update({},{$set:{
|
||||
'flags.tour.intro':-2,
|
||||
//'flags.tour.classes':-2,
|
||||
'flags.tour.stats':-2,
|
||||
'flags.tour.tavern':-2,
|
||||
'flags.tour.party':-2,
|
||||
'flags.tour.guilds':-2,
|
||||
'flags.tour.challenges':-2,
|
||||
'flags.tour.market':-2
|
||||
}},{multi:1})
|
||||
@@ -1,64 +0,0 @@
|
||||
var migrationName = '20150224_force_resting_in_inn';
|
||||
var authorName = 'Alys'; // in case script author needs to know when their ...
|
||||
var authorUuid = 'd904bd62-da08-416b-a816-ba797c9ee265'; //... own data is done
|
||||
|
||||
/*
|
||||
* force all active players to rest in the inn due to massive server fail
|
||||
*/
|
||||
|
||||
// IMPORTANT NOTE: this migration was written when we were using version 3 of lodash.
|
||||
// We've now upgraded to lodash v4 but the code used in this migration has not been
|
||||
// adapted to work with it. Before this migration is used again any lodash method should
|
||||
// be checked for compatibility against the v4 changelog and changed if necessary.
|
||||
// https://github.com/lodash/lodash/wiki/Changelog#v400
|
||||
|
||||
var dbserver = 'localhost:27017' // CHANGE THIS FOR PRODUCTION DATABASE
|
||||
|
||||
var mongo = require('mongoskin');
|
||||
var _ = require('lodash');
|
||||
|
||||
var dbUsers = mongo.db(dbserver + '/habitrpg?auto_reconnect').collection('users');
|
||||
|
||||
var query = {
|
||||
'auth.timestamps.loggedin':{$gt:new Date('2015-02-22')}
|
||||
};
|
||||
|
||||
var fields = {
|
||||
'preferences.sleep':1,
|
||||
};
|
||||
|
||||
console.warn('Updating users...');
|
||||
var progressCount = 1000;
|
||||
var count = 0;
|
||||
dbUsers.findEach(query, fields, {batchSize:250}, function(err, user) {
|
||||
if (err) { return exiting(1, 'ERROR! ' + err); }
|
||||
if (!user) {
|
||||
console.warn('All appropriate users found and modified.');
|
||||
return displayData();
|
||||
}
|
||||
count++;
|
||||
|
||||
var set = {'migration':migrationName, 'preferences.sleep':1 };
|
||||
dbUsers.update({_id:user._id}, {$set:set});
|
||||
|
||||
if (count%progressCount == 0) console.warn(count + ' ' + user._id);
|
||||
if (user._id == authorUuid) console.warn(authorName + ' processed');
|
||||
if (user._id == '9' ) console.warn('lefnire' + ' 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);
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
db.users.update(
|
||||
{'achievements.helpedHabit':true},
|
||||
{$set:{'achievements.habitSurveys':1}},
|
||||
{multi:1}
|
||||
)
|
||||
@@ -1,138 +0,0 @@
|
||||
// var migrationName = '20150604_ultimateGearSets';
|
||||
// var authorName = 'Sabe'; // in case script author needs to know when their ...
|
||||
// var authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; //... own data is done
|
||||
|
||||
var migrationName = '20150620_ultimateGearSets';
|
||||
var authorName = 'Alys'; // in case script author needs to know when their ...
|
||||
var authorUuid = 'd904bd62-da08-416b-a816-ba797c9ee265'; //... own data is done
|
||||
|
||||
/*
|
||||
* grant the new ultimateGearSets achievement for existing users' collected equipment
|
||||
*
|
||||
*
|
||||
* Changed by Alys on 20150620 to assign false values to
|
||||
* 'achievements.ultimateGearSets' when true values are not appropriate,
|
||||
* because of https://github.com/HabitRPG/habitrpg/issues/5427
|
||||
*
|
||||
* Minimal changes were made so the code isn't as efficient or clean
|
||||
* as it could be, but it's (hopefully) one-use-only and minimal changes
|
||||
* means minimal new testing.
|
||||
*/
|
||||
|
||||
// IMPORTANT NOTE: this migration was written when we were using version 3 of lodash.
|
||||
// We've now upgraded to lodash v4 but the code used in this migration has not been
|
||||
// adapted to work with it. Before this migration is used again any lodash method should
|
||||
// be checked for compatibility against the v4 changelog and changed if necessary.
|
||||
// https://github.com/lodash/lodash/wiki/Changelog#v400
|
||||
|
||||
var dbserver = 'localhost:27017' // FOR TEST DATABASE
|
||||
// var dbserver = 'username:password@ds031379-a0.mongolab.com:31379' // FOR PRODUCTION DATABASE
|
||||
var dbname = 'habitrpg';
|
||||
|
||||
var mongo = require('mongoskin');
|
||||
var _ = require('lodash');
|
||||
|
||||
var dbUsers = mongo.db(dbserver + '/' + dbname + '?auto_reconnect').collection('users');
|
||||
|
||||
var fields = {
|
||||
'achievements.ultimateGearSets':1,
|
||||
'items.gear.owned':1
|
||||
};
|
||||
|
||||
|
||||
// Changes 20150620: All users have to be processed now (non-achievers need
|
||||
// false values).
|
||||
var query = {
|
||||
};
|
||||
|
||||
console.warn('Updating users...');
|
||||
var progressCount = 1000;
|
||||
var count = 0;
|
||||
dbUsers.findEach(query, fields, {batchSize:250}, function(err, user) {
|
||||
if (err) { return exiting(1, 'ERROR! ' + err); }
|
||||
if (!user) {
|
||||
console.warn('All appropriate users found and modified.');
|
||||
return displayData();
|
||||
}
|
||||
count++;
|
||||
|
||||
var achievements = {};
|
||||
var changeUser = false;
|
||||
// Changes 20150620: 'changeUser' now indicates that the user must have the
|
||||
// Enchanted Armoire unlocked.
|
||||
if ( (typeof user.items.gear.owned.weapon_wizard_6 !== 'undefined')
|
||||
&& (typeof user.items.gear.owned.armor_wizard_5 !== 'undefined')
|
||||
&& (typeof user.items.gear.owned.head_wizard_5 !== 'undefined')
|
||||
) {
|
||||
achievements['wizard'] = true;
|
||||
changeUser = true;
|
||||
}
|
||||
else {
|
||||
// Changes 20150620: false added for all classes (here and below)
|
||||
achievements['wizard'] = false;
|
||||
}
|
||||
|
||||
if ( (typeof user.items.gear.owned.weapon_warrior_6 !== 'undefined')
|
||||
&& (typeof user.items.gear.owned.armor_warrior_5 !== 'undefined')
|
||||
&& (typeof user.items.gear.owned.head_warrior_5 !== 'undefined')
|
||||
&& (typeof user.items.gear.owned.shield_warrior_5 !== 'undefined')
|
||||
) {
|
||||
achievements['warrior'] = true;
|
||||
changeUser = true;
|
||||
}
|
||||
else {
|
||||
achievements['warrior'] = false;
|
||||
}
|
||||
|
||||
if ( (typeof user.items.gear.owned.weapon_healer_6 !== 'undefined')
|
||||
&& (typeof user.items.gear.owned.armor_healer_5 !== 'undefined')
|
||||
&& (typeof user.items.gear.owned.head_healer_5 !== 'undefined')
|
||||
&& (typeof user.items.gear.owned.shield_healer_5 !== 'undefined')
|
||||
) {
|
||||
achievements['healer'] = true;
|
||||
changeUser = true;
|
||||
}
|
||||
else {
|
||||
achievements['healer'] = false;
|
||||
}
|
||||
|
||||
if ( (typeof user.items.gear.owned.weapon_rogue_6 !== 'undefined')
|
||||
&& (typeof user.items.gear.owned.armor_rogue_5 !== 'undefined')
|
||||
&& (typeof user.items.gear.owned.head_rogue_5 !== 'undefined')
|
||||
&& (typeof user.items.gear.owned.shield_rogue_6 !== 'undefined')
|
||||
) {
|
||||
achievements['rogue'] = true;
|
||||
changeUser = true;
|
||||
}
|
||||
else {
|
||||
achievements['rogue'] = false;
|
||||
}
|
||||
|
||||
// Changes 20150620: $set is now run for all users.
|
||||
var set = {'migration':migrationName, 'achievements.ultimateGearSets':achievements};
|
||||
if (changeUser) { // user has at least one Ultimate Gear achievement
|
||||
set['flags.armoireEnabled'] = 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');
|
||||
if (user._id == '9' ) console.warn('lefnire' + ' 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);
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
db.users.update(
|
||||
{},
|
||||
{$set:{'items.mounts.Gryphon-RoyalPurple':true}},
|
||||
{multi:true}
|
||||
);
|
||||
@@ -1,5 +0,0 @@
|
||||
db.users.update(
|
||||
{'items.pets.Wolf-Veteran':{$ne:null}},
|
||||
{$set:{'items.pets.Tiger-Veteran':5}},
|
||||
{multi:true}
|
||||
);
|
||||
@@ -1,7 +0,0 @@
|
||||
// Run after the Veteran Tiger script, not before!
|
||||
|
||||
db.users.update(
|
||||
{'items.pets.Wolf-Veteran':{$exists:false}},
|
||||
{$set:{'items.pets.Wolf-Veteran':5}},
|
||||
{multi:true}
|
||||
);
|
||||
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* Make sure leaders are existing users
|
||||
*/
|
||||
|
||||
var mongo = require('mongoskin');
|
||||
var async = require('async');
|
||||
|
||||
var dbserver = 'url';
|
||||
var dbname = 'dbname';
|
||||
var countGroups = 0;
|
||||
var countUsers = 0;
|
||||
|
||||
var db = mongo.db(dbserver + '/' + dbname + '?auto_reconnect');
|
||||
var dbUsers = db.collection('users');
|
||||
var dbGroups = db.collection('groups');
|
||||
|
||||
console.log('Begins work on db');
|
||||
|
||||
function findGroups(gt){
|
||||
var query = {};
|
||||
if(gt) query._id = {$gt: gt};
|
||||
|
||||
console.log(query)
|
||||
|
||||
dbGroups.find(query, {
|
||||
fields: {_id: 1, members: 1, leader: 1},
|
||||
limit: 10000,
|
||||
sort: {
|
||||
_id: 1
|
||||
}
|
||||
}).toArray(function(err, groups){
|
||||
if(err) throw err;
|
||||
|
||||
var lastGroup = null;
|
||||
if(groups.length === 10000){
|
||||
lastGroup = groups[groups.length - 1];
|
||||
}
|
||||
|
||||
async.eachLimit(groups, 30, function(group, cb1){
|
||||
countGroups++;
|
||||
console.log('Group: ', countGroups, group._id);
|
||||
|
||||
var members = group.members;
|
||||
|
||||
dbUsers.findOne({_id: group.leader}, {fields: {_id: 1}}, function(err, user){
|
||||
if(err) return cb1(err);
|
||||
|
||||
// If leader has deleted account
|
||||
if(!user && (group._id !== 'habitrpg') && members && members[0]) {
|
||||
dbGroups.update({
|
||||
_id: group._id
|
||||
}, {
|
||||
$set: {
|
||||
// Set first user as new leader
|
||||
leader: members[0]
|
||||
}
|
||||
}, {
|
||||
multi: false
|
||||
}, function(err, res){
|
||||
if(err) return cb1(err);
|
||||
|
||||
console.log('Updated: ', res);
|
||||
return cb1();
|
||||
});
|
||||
}else{
|
||||
return cb1();
|
||||
}
|
||||
});
|
||||
}, function(err){
|
||||
if(err) throw err;
|
||||
|
||||
if(lastGroup && lastGroup._id){
|
||||
findGroups(lastGroup._id);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
findGroups();
|
||||
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
* Remove deleted accounts from groups
|
||||
*/
|
||||
|
||||
var mongo = require('mongoskin');
|
||||
var async = require('async');
|
||||
|
||||
var dbserver = 'url';
|
||||
var dbname = 'dbname';
|
||||
var countGroups = 0;
|
||||
var countUsers = 0;
|
||||
|
||||
var db = mongo.db(dbserver + '/' + dbname + '?auto_reconnect');
|
||||
var dbUsers = db.collection('users');
|
||||
var dbGroups = db.collection('groups');
|
||||
|
||||
console.log('Begins work on db');
|
||||
|
||||
function findGroups(gt){
|
||||
var query = {};
|
||||
if(gt) query._id = {$gt: gt};
|
||||
|
||||
console.log(query)
|
||||
|
||||
dbGroups.find(query, {
|
||||
fields: {_id: 1, members: 1},
|
||||
limit: 10000,
|
||||
sort: {
|
||||
_id: 1
|
||||
}
|
||||
}).toArray(function(err, groups){
|
||||
if(err) throw err;
|
||||
|
||||
var lastGroup = null;
|
||||
if(groups.length === 10000){
|
||||
lastGroup = groups[groups.length - 1];
|
||||
}
|
||||
|
||||
async.eachLimit(groups, 3, function(group, cb1){
|
||||
countGroups++;
|
||||
console.log('Group: ', countGroups, group._id);
|
||||
|
||||
var members = group.members;
|
||||
|
||||
// Remove users who deleted their account
|
||||
async.eachLimit(members, 15, function(member, cb2){
|
||||
dbUsers.findOne({_id: member}, {fields: {_id: 1}}, function(err, user){
|
||||
if(err) return cb2(err);
|
||||
|
||||
if(!user){
|
||||
countUsers++;
|
||||
console.log('User removed n. ', countUsers, 'user id ', member, 'group id ', group._id);
|
||||
|
||||
dbGroups.update({
|
||||
_id: group._id
|
||||
}, {
|
||||
$pull: {members: member},
|
||||
$inc: {memberCount: -1}
|
||||
}, {
|
||||
multi: false
|
||||
}, function(err, res){
|
||||
if(err) return cb2(err);
|
||||
|
||||
console.log('Updated: ', res);
|
||||
return cb2();
|
||||
});
|
||||
}else{
|
||||
cb2();
|
||||
}
|
||||
});
|
||||
}, function(err){
|
||||
if(err) return cb1(err);
|
||||
|
||||
cb1();
|
||||
});
|
||||
|
||||
}, function(err){
|
||||
if(err) throw err;
|
||||
|
||||
if(lastGroup && lastGroup._id){
|
||||
findGroups(lastGroup._id);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
findGroups();
|
||||
@@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Remove empty private groups
|
||||
*/
|
||||
|
||||
var mongo = require('mongoskin');
|
||||
|
||||
var dbserver = 'url';
|
||||
var dbname = 'name';
|
||||
|
||||
var db = mongo.db(dbserver + '/' + dbname + '?auto_reconnect');
|
||||
var dbGroups = db.collection('groups');
|
||||
|
||||
console.log('Begins work on db');
|
||||
|
||||
dbGroups.findEach({
|
||||
memberCount: 0,
|
||||
}, {_id: 1}, function(err, res){
|
||||
if(err) throw err;
|
||||
|
||||
console.log(res);
|
||||
});
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Sync groups with Firebase
|
||||
*/
|
||||
|
||||
var mongo = require('mongoskin');
|
||||
var Firebase = require('Firebase');
|
||||
|
||||
var dbserver = 'mongodb://url';
|
||||
var dbname = 'db';
|
||||
|
||||
var db = mongo.db(dbserver + '/' + dbname + '?auto_reconnect');
|
||||
var dbGroups = db.collection('groups');
|
||||
var countGroups = 0;
|
||||
|
||||
var firebaseRef = new Firebase('https://' + 'firebase-app' + '.firebaseio.com');
|
||||
|
||||
// TODO handle sync errors with firebase?
|
||||
firebaseRef.authWithCustomToken('firebase-secret', function(err, authData){
|
||||
if(err) throw new Error('Impossible to authenticate Firebase');
|
||||
|
||||
console.log('Firebase connected, begins work on db');
|
||||
|
||||
dbGroups.findEach({}, {_id: 1, members: 1}, {batchSize: 100}, function(err, group){
|
||||
if(err) throw err;
|
||||
if(group._id !== 'habitrpg') return;
|
||||
|
||||
countGroups++;
|
||||
console.log('Group: ', countGroups);
|
||||
|
||||
firebaseRef.child('rooms/' + group._id)
|
||||
.set({
|
||||
name: group.name
|
||||
});
|
||||
|
||||
group.members.forEach(function(member){
|
||||
firebaseRef.child('members/' + group._id + '/' + userId)
|
||||
.set(true);
|
||||
|
||||
firebaseRef.child('users/' + member + '/rooms/' + group._id)
|
||||
.set(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,67 +0,0 @@
|
||||
var migrationName = '20151013_jackolanterns.js';
|
||||
var authorName = 'Sabe'; // in case script author needs to know when their ...
|
||||
var authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; //... own data is done
|
||||
|
||||
/*
|
||||
* Award Jack-O'-Lantern mounts to users who already have the pet version, award pet if they don't
|
||||
*/
|
||||
|
||||
var dbserver = 'localhost:27017'; // FOR TEST DATABASE
|
||||
// var dbserver = 'username:password@ds031379-a0.mongolab.com:31379'; // FOR PRODUCTION DATABASE
|
||||
var dbname = 'habitrpg';
|
||||
|
||||
var mongo = require('mongoskin');
|
||||
var _ = require('lodash');
|
||||
|
||||
var dbUsers = mongo.db(dbserver + '/' + dbname + '?auto_reconnect').collection('users');
|
||||
|
||||
// specify a query to limit the affected users (empty for all users):
|
||||
var query = {
|
||||
};
|
||||
|
||||
// specify fields we are interested in to limit retrieved data (empty if we're not reading data):
|
||||
var fields = {
|
||||
'items.pets.JackOLantern-Base':1
|
||||
};
|
||||
|
||||
console.warn('Updating users...');
|
||||
var progressCount = 1000;
|
||||
var count = 0;
|
||||
dbUsers.findEach(query, fields, {batchSize:250}, function(err, user) {
|
||||
if (err) { return exiting(1, 'ERROR! ' + err); }
|
||||
if (!user) {
|
||||
console.warn('All appropriate users found and modified.');
|
||||
return displayData();
|
||||
}
|
||||
count++;
|
||||
|
||||
// specify user data to change:
|
||||
var set = {};
|
||||
if (user.items.pets['JackOLantern-Base']) {
|
||||
set = {'migration':migrationName, 'items.mounts.JackOLantern-Base':true};
|
||||
} else {
|
||||
set = {'migration':migrationName, 'items.pets.JackOLantern-Base':5};
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Migrate email to lowerCase version and add auth.local.lowerCaseUsername email
|
||||
*/
|
||||
|
||||
var mongo = require('mongoskin');
|
||||
var async = require('async');
|
||||
|
||||
var dbserver = 'url';
|
||||
var dbname = 'dbname';
|
||||
var countUsers = 0;
|
||||
|
||||
var db = mongo.db(dbserver + '/' + dbname + '?auto_reconnect');
|
||||
var dbUsers = db.collection('users');
|
||||
|
||||
console.log('Begins work on db');
|
||||
|
||||
function findUsers(gt){
|
||||
var query = {};
|
||||
if(gt) query._id = {$gt: gt};
|
||||
|
||||
console.log(query)
|
||||
|
||||
dbUsers.find(query, {
|
||||
fields: {_id: 1, auth: 1},
|
||||
limit: 10000,
|
||||
sort: {
|
||||
_id: 1
|
||||
}
|
||||
}).toArray(function(err, users){
|
||||
if(err) throw err;
|
||||
|
||||
var lastUser = null;
|
||||
if(users.length === 10000){
|
||||
lastUser = users[users.length - 1];
|
||||
}
|
||||
|
||||
async.eachLimit(users, 20, function(user, cb){
|
||||
countUsers++;
|
||||
console.log('User: ', countUsers, user._id);
|
||||
|
||||
var update = {
|
||||
$set: {}
|
||||
};
|
||||
|
||||
if(user.auth && user.auth.local) {
|
||||
if(user.auth.local.username) update['$set']['auth.local.lowerCaseUsername'] = user.auth.local.username.toLowerCase();
|
||||
if(user.auth.local.email) update['$set']['auth.local.email'] = user.auth.local.email.toLowerCase();
|
||||
}
|
||||
|
||||
dbUsers.update({
|
||||
_id: user._id
|
||||
}, update, cb);
|
||||
}, function(err){
|
||||
if(err) throw err;
|
||||
|
||||
if(lastUser && lastUser._id){
|
||||
findUsers(lastUser._id);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
findUsers();
|
||||
@@ -1,63 +0,0 @@
|
||||
var migrationName = '20151105_tutorial_flags_v1';
|
||||
var authorName = 'Alys'; // in case script author needs to know when their ...
|
||||
var authorUuid = 'd904bd62-da08-416b-a816-ba797c9ee265'; //... own data is done
|
||||
|
||||
/*
|
||||
* set flags.tutorial.ios and flags.tutorial.main flags to true in preparation
|
||||
* for the release of a new iOS tutorial
|
||||
*
|
||||
*/
|
||||
|
||||
// var dbserver = 'localhost:27017' // FOR TEST DATABASE
|
||||
var dbserver = 'alys:@ds031379-a0.mongolab.com:31379' // FOR PRODUCTION DATABASE
|
||||
var dbname = 'habitrpg';
|
||||
|
||||
var mongo = require('mongoskin');
|
||||
var _ = require('lodash');
|
||||
|
||||
var dbUsers = mongo.db(dbserver + '/' + dbname + '?auto_reconnect').collection('users');
|
||||
|
||||
var fields = {
|
||||
};
|
||||
|
||||
|
||||
var query = {
|
||||
'auth.timestamps.loggedin':{$gt:new Date('2015-10-20')}
|
||||
};
|
||||
|
||||
console.warn('Updating users...');
|
||||
var progressCount = 1000;
|
||||
var count = 0;
|
||||
dbUsers.findEach(query, fields, {batchSize:250}, function(err, user) {
|
||||
if (err) { return exiting(1, 'ERROR! ' + err); }
|
||||
if (!user) {
|
||||
console.warn('All appropriate users found and modified.');
|
||||
return displayData();
|
||||
}
|
||||
count++;
|
||||
|
||||
// var set = {'migration':migrationName, 'flags.tutorial.ios':true, 'flags.tutorial.main':true };
|
||||
var set = {'migration':migrationName, 'flags.tutorial.ios':{} };
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
var migrationName = '20151116_costume_contest.js';
|
||||
var authorName = 'Sabe'; // in case script author needs to know when their ...
|
||||
var authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; //... own data is done
|
||||
|
||||
/*
|
||||
* Award Costume Contest achievement to 2015 winners
|
||||
*/
|
||||
|
||||
var dbserver = 'localhost:27017'; // FOR TEST DATABASE
|
||||
// var dbserver = 'username:password@ds031379-a0.mongolab.com:31379'; // FOR PRODUCTION DATABASE
|
||||
var dbname = 'habitrpg';
|
||||
|
||||
var mongo = require('mongoskin');
|
||||
var _ = require('lodash');
|
||||
|
||||
var dbUsers = mongo.db(dbserver + '/' + dbname + '?auto_reconnect').collection('users');
|
||||
|
||||
// specify a query to limit the affected users (empty for all users):
|
||||
var query = {
|
||||
_id: {
|
||||
$in: [
|
||||
'e411dab3-a4ca-414d-bdbd-b6940b3bdeb3',
|
||||
'35ced5cc-c33a-45c8-93dc-16000ee66fde',
|
||||
'ab3f0549-7247-4fd5-975b-efcff98c79c3',
|
||||
'b1261fd2-eb25-46b4-97a9-ae7a0dc8a131',
|
||||
'1f27893f-3808-4724-9725-f46dab93faca',
|
||||
'216a0c23-6afd-4a5e-b434-d386a10862a2',
|
||||
'2d6ef231-50b4-4a22-90e7-45eb97147a2c',
|
||||
'98b8cf4f-89bd-4b0a-988d-02629a217232',
|
||||
'c5183dfa-c741-43ce-935e-c6d89b41a030',
|
||||
'262a7afb-6b57-4d81-88e0-80d2e9f6cbdc',
|
||||
'33991e0a-de55-4986-ac81-af78491a84de',
|
||||
'7adf6ada-3c05-4054-b5df-fa7d49d3b9eb',
|
||||
'235a1cbd-48c5-41b1-afb4-59d2f8645c57',
|
||||
'b7617a61-188b-4332-bf4d-32268fa77f2b',
|
||||
'672c1ce0-9f47-44f0-a3f3-8cc3c6c5a9cb',
|
||||
'd0a3217a-7b92-48d6-b39a-b1b1be96702e',
|
||||
'5ef910dc-1d22-47d9-aa38-a60132c60679',
|
||||
'370a44c8-e94a-4a2c-91f2-33166926db1f',
|
||||
'1b0b3ef3-28bd-4046-a49b-e1c83e281baf',
|
||||
'75b93321-66b9-49bd-9076-052499c1d2bf',
|
||||
'd97516e4-81d0-4f60-bf03-95f7330925ab',
|
||||
'3e13cc79-de38-420d-822e-9e9da309ce6b',
|
||||
'0e471dc1-ecb0-4388-a891-b873a237d2cf',
|
||||
'ca3da398-4f73-4304-b838-af3669ed4cbb',
|
||||
'44cdf105-8bda-4197-9d1a-1bcb83b4dc84',
|
||||
'5419830c-b837-4573-ae82-4718ab95b7f1',
|
||||
'ac6fbe37-b0dc-40d8-ba14-77dde66fbfa8',
|
||||
'8789ba18-a498-46b9-b367-3b929a0acb94',
|
||||
'52fce1a9-9b0a-4e26-95dc-adc12f52e752',
|
||||
'21bf71ac-399c-470b-abe0-cc49a03b6a8b',
|
||||
'f1618ce2-552e-4f23-bc76-e73d63ebedd0',
|
||||
'4cc0c749-d943-4090-b529-42bc665b7244',
|
||||
'e259682e-cb5c-4d94-b472-ceedc66d7484',
|
||||
'fa197a4b-e065-4551-803a-c8a5b9970f9d'
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
// specify fields we are interested in to limit retrieved data (empty if we're not reading data):
|
||||
var fields = {
|
||||
};
|
||||
|
||||
console.warn('Updating users...');
|
||||
var progressCount = 1000;
|
||||
var count = 0;
|
||||
dbUsers.findEach(query, fields, {batchSize:250}, function(err, user) {
|
||||
if (err) { return exiting(1, 'ERROR! ' + err); }
|
||||
if (!user) {
|
||||
console.warn('All appropriate users found and modified.');
|
||||
return displayData();
|
||||
}
|
||||
count++;
|
||||
|
||||
// specify user data to change:
|
||||
var set = {'migration':migrationName};
|
||||
var inc = {'achievements.costumeContests':1};
|
||||
|
||||
dbUsers.update({_id:user._id}, {$set:set});
|
||||
dbUsers.update({_id:user._id}, {$inc:inc});
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
var migrationName = '20151116_costume_contest_to_number.js';
|
||||
var authorName = 'Sabe'; // in case script author needs to know when their ...
|
||||
var authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; //... own data is done
|
||||
|
||||
/*
|
||||
* Change Costume Contest achievement from Boolean to Number, so people can win repeatedly
|
||||
*/
|
||||
|
||||
var dbserver = 'localhost:27017'; // FOR TEST DATABASE
|
||||
// var dbserver = 'username:password@ds031379-a0.mongolab.com:31379'; // FOR PRODUCTION DATABASE
|
||||
var dbname = 'habitrpg';
|
||||
|
||||
var mongo = require('mongoskin');
|
||||
var _ = require('lodash');
|
||||
|
||||
var dbUsers = mongo.db(dbserver + '/' + dbname + '?auto_reconnect').collection('users');
|
||||
|
||||
// specify a query to limit the affected users (empty for all users):
|
||||
var query = {
|
||||
'achievements.costumeContest':true
|
||||
};
|
||||
|
||||
// specify fields we are interested in to limit retrieved data (empty if we're not reading data):
|
||||
var fields = {
|
||||
'achievements.costumeContest':1
|
||||
};
|
||||
|
||||
console.warn('Updating users...');
|
||||
var progressCount = 1000;
|
||||
var count = 0;
|
||||
dbUsers.findEach(query, fields, {batchSize:250}, function(err, user) {
|
||||
if (err) { return exiting(1, 'ERROR! ' + err); }
|
||||
if (!user) {
|
||||
console.warn('All appropriate users found and modified.');
|
||||
return displayData();
|
||||
}
|
||||
count++;
|
||||
|
||||
// specify user data to change:
|
||||
var set = {'achievements.costumeContests':1};
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
var migrationName = '20151125_turkey_ladder.js';
|
||||
var authorName = 'Sabe'; // in case script author needs to know when their ...
|
||||
var authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; //... own data is done
|
||||
|
||||
/*
|
||||
* Award Gilded Turkey pet to Turkey mount owners, Turkey Mount if they only have Turkey Pet,
|
||||
* and Turkey Pet otherwise
|
||||
*/
|
||||
|
||||
var dbserver = 'localhost:27017'; // FOR TEST DATABASE
|
||||
// var dbserver = 'username:password@ds031379-a0.mongolab.com:31379'; // FOR PRODUCTION DATABASE
|
||||
var dbname = 'habitrpg';
|
||||
|
||||
var mongo = require('mongoskin');
|
||||
var _ = require('lodash');
|
||||
|
||||
var dbUsers = mongo.db(dbserver + '/' + dbname + '?auto_reconnect').collection('users');
|
||||
|
||||
// specify a query to limit the affected users (empty for all users):
|
||||
var query = {
|
||||
};
|
||||
|
||||
// specify fields we are interested in to limit retrieved data (empty if we're not reading data):
|
||||
var fields = {
|
||||
'items.pets.Turkey-Base': 1,
|
||||
'items.mounts.Turkey-Base': 1
|
||||
};
|
||||
|
||||
console.warn('Updating users...');
|
||||
var progressCount = 1000;
|
||||
var count = 0;
|
||||
dbUsers.findEach(query, fields, {batchSize:250}, function(err, user) {
|
||||
if (err) { return exiting(1, 'ERROR! ' + err); }
|
||||
if (!user) {
|
||||
console.warn('All appropriate users found and modified.');
|
||||
return displayData();
|
||||
}
|
||||
count++;
|
||||
|
||||
// specify user data to change:
|
||||
var set = {};
|
||||
if (user.items.mounts['Turkey-Base']) {
|
||||
set = {'migration':migrationName, 'items.pets.Turkey-Gilded':5};
|
||||
} else if (user.items.pets['Turkey-Base']) {
|
||||
set = {'migration':migrationName, 'items.mounts.Turkey-Base':true};
|
||||
} else {
|
||||
set = {'migration':migrationName, 'items.pets.Turkey-Base':5};
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
var migrationName = '20151229_new_years_hats.js';
|
||||
var authorName = 'Sabe'; // in case script author needs to know when their ...
|
||||
var authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; //... own data is done
|
||||
|
||||
/*
|
||||
* Award 2015 party hat if user has 2014 hat, 2014 hat if they have the 2013 hat,
|
||||
* and 2013 hat otherwise
|
||||
*/
|
||||
|
||||
var dbserver = 'localhost:27017'; // FOR TEST DATABASE
|
||||
// var dbserver = 'username:password@ds031379-a0.mongolab.com:31379'; // FOR PRODUCTION DATABASE
|
||||
var dbname = 'habitrpg';
|
||||
|
||||
var mongo = require('mongoskin');
|
||||
var _ = require('lodash');
|
||||
|
||||
var dbUsers = mongo.db(dbserver + '/' + dbname + '?auto_reconnect').collection('users');
|
||||
|
||||
// specify a query to limit the affected users (empty for all users):
|
||||
var query = {
|
||||
};
|
||||
|
||||
// specify fields we are interested in to limit retrieved data (empty if we're not reading data):
|
||||
var fields = {
|
||||
'items.gear.owned': 1,
|
||||
};
|
||||
|
||||
console.warn('Updating users...');
|
||||
var progressCount = 1000;
|
||||
var count = 0;
|
||||
dbUsers.findEach(query, fields, {batchSize:250}, function(err, user) {
|
||||
if (err) { return exiting(1, 'ERROR! ' + err); }
|
||||
if (!user) {
|
||||
console.warn('All appropriate users found and modified.');
|
||||
return displayData();
|
||||
}
|
||||
count++;
|
||||
|
||||
// specify user data to change:
|
||||
var set = {};
|
||||
if (user.items && user.items.gear && user.items.gear.owned && user.items.gear.owned.hasOwnProperty('head_special_nye2014')) {
|
||||
set = {'migration':migrationName, 'items.gear.owned.head_special_nye2015':false};
|
||||
} else if (user.items && user.items.gear && user.items.gear.owned && user.items.gear.owned.hasOwnProperty('head_special_nye')) {
|
||||
set = {'migration':migrationName, 'items.gear.owned.head_special_nye2014':false};
|
||||
} else {
|
||||
set = {'migration':migrationName, 'items.gear.owned.head_special_nye':false};
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
var migrationName = '20160521_veteran_ladder.js';
|
||||
var authorName = 'Sabe'; // in case script author needs to know when their ...
|
||||
var authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; //... own data is done
|
||||
|
||||
/*
|
||||
* Award Gilded Turkey pet to Turkey mount owners, Turkey Mount if they only have Turkey Pet,
|
||||
* and Turkey Pet otherwise
|
||||
*/
|
||||
|
||||
var dbserver = 'localhost:27017'; // FOR TEST DATABASE
|
||||
// var dbserver = 'username:password@ds031379-a0.mongolab.com:31379'; // FOR PRODUCTION DATABASE
|
||||
var dbname = 'habitrpg';
|
||||
|
||||
var mongo = require('mongoskin');
|
||||
var _ = require('lodash');
|
||||
|
||||
// IMPORTANT NOTE: this migration was written when we were using version 3 of lodash.
|
||||
// We've now upgraded to lodash v4 but the code used in this migration has not been
|
||||
// adapted to work with it. Before this migration is used again any lodash method should
|
||||
// be checked for compatibility against the v4 changelog and changed if necessary.
|
||||
// https://github.com/lodash/lodash/wiki/Changelog#v400
|
||||
|
||||
var dbUsers = mongo.db(dbserver + '/' + dbname + '?auto_reconnect').collection('users');
|
||||
|
||||
// specify a query to limit the affected users (empty for all users):
|
||||
var query = {
|
||||
'auth.timestamps.loggedin':{$gt:new Date('2016-05-01')} // remove when running migration a second time
|
||||
};
|
||||
|
||||
// specify fields we are interested in to limit retrieved data (empty if we're not reading data):
|
||||
var fields = {
|
||||
'migration': 1,
|
||||
'items.pets.Wolf-Veteran': 1,
|
||||
'items.pets.Tiger-Veteran': 1
|
||||
};
|
||||
|
||||
console.warn('Updating users...');
|
||||
var progressCount = 1000;
|
||||
var count = 0;
|
||||
dbUsers.findEach(query, fields, {batchSize:250}, function(err, user) {
|
||||
if (err) { return exiting(1, 'ERROR! ' + err); }
|
||||
if (!user) {
|
||||
console.warn('All appropriate users found and modified.');
|
||||
return displayData();
|
||||
}
|
||||
count++;
|
||||
|
||||
// specify user data to change:
|
||||
var set = {};
|
||||
if (user.migration !== migrationName) {
|
||||
if (user.items.pets['Tiger-Veteran']) {
|
||||
set = {'migration':migrationName, 'items.pets.Lion-Veteran':5};
|
||||
} else if (user.items.pets['Wolf-Veteran']) {
|
||||
set = {'migration':migrationName, 'items.pets.Tiger-Veteran':5};
|
||||
} else {
|
||||
set = {'migration':migrationName, 'items.pets.Wolf-Veteran':5};
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
var uuid = require('uuid').v4;
|
||||
var mongo = require('mongodb').MongoClient;
|
||||
var _ = require('lodash');
|
||||
|
||||
// IMPORTANT NOTE: this migration was written when we were using version 3 of lodash.
|
||||
// We've now upgraded to lodash v4 but the code used in this migration has not been
|
||||
// adapted to work with it. Before this migration is used again any lodash method should
|
||||
// be checked for compatibility against the v4 changelog and changed if necessary.
|
||||
// https://github.com/lodash/lodash/wiki/Changelog#v400
|
||||
|
||||
var taskIds = require('checklists-no-id.json').map(function (obj) {
|
||||
return obj._id;
|
||||
});
|
||||
|
||||
// Fix empty task.checklistt.id
|
||||
|
||||
var progressCount = 100;
|
||||
var count = 0;
|
||||
|
||||
function displayData() {
|
||||
console.warn('\n' + count + ' tasks 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); }
|
||||
}
|
||||
}
|
||||
|
||||
mongo.connect('db url')
|
||||
.then(function (db) {
|
||||
var dbTasks = db.collection('tasks');
|
||||
|
||||
// specify a query to limit the affected tasks (empty for all tasks):
|
||||
var query = {
|
||||
'_id':{ $in: taskIds },
|
||||
};
|
||||
|
||||
// specify fields we are interested in to limit retrieved data (empty if we're not reading data):
|
||||
var fields = {
|
||||
'checklist': 1,
|
||||
};
|
||||
|
||||
console.warn('Updating tasks...');
|
||||
|
||||
dbTasks.find(query, fields, {batchSize: 250}).toArray(function(err, tasks) {
|
||||
if (err) { return exiting(1, 'ERROR! ' + err); }
|
||||
|
||||
tasks.forEach(function (task) {
|
||||
var checklist = task.checklist || [];
|
||||
checklist.forEach(function (item) {
|
||||
if (!item.id || item.id === "") {
|
||||
item.id = uuid();
|
||||
}
|
||||
});
|
||||
|
||||
// specify user data to change:
|
||||
var set = {
|
||||
checklist: checklist,
|
||||
};
|
||||
//console.log(set);
|
||||
|
||||
dbTasks.update({_id: task._id}, {$set: set}, function (err, res) {
|
||||
if (err) console.error('Error while updating', err);
|
||||
});
|
||||
|
||||
count++;
|
||||
if (count % progressCount == 0) console.warn(count + ' ' + task._id);
|
||||
});
|
||||
|
||||
if (count === tasks.length) {
|
||||
console.warn('All appropriate tasks found and modified.');
|
||||
return displayData();
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(function (err) {
|
||||
throw err;
|
||||
});
|
||||
@@ -1,82 +0,0 @@
|
||||
var migrationName = '20160731_naming_day.js';
|
||||
var authorName = 'Sabe'; // in case script author needs to know when their ...
|
||||
var authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; //... own data is done
|
||||
|
||||
/*
|
||||
* Award Royal Purple Gryphon pet to Royal Purple Gryphon mount owners, mount to everyone else
|
||||
*/
|
||||
|
||||
var mongo = require('mongoskin');
|
||||
|
||||
var connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
|
||||
|
||||
var dbUsers = mongo.db(connectionString).collection('users');
|
||||
|
||||
// specify a query to limit the affected users (empty for all users):
|
||||
var query = {
|
||||
'migration':{$ne:migrationName},
|
||||
'auth.timestamps.loggedin':{$gt:new Date('2016-07-30')} // Extend timeframe each run of migration
|
||||
};
|
||||
|
||||
// specify fields we are interested in to limit retrieved data (empty if we're not reading data):
|
||||
var fields = {
|
||||
'items.mounts': 1
|
||||
};
|
||||
|
||||
console.warn('Updating users...');
|
||||
var progressCount = 1000;
|
||||
var count = 0;
|
||||
dbUsers.findEach(query, fields, {batchSize:250}, function(err, user) {
|
||||
if (err) { return exiting(1, 'ERROR! ' + err); }
|
||||
if (!user) {
|
||||
console.warn('All appropriate users found and modified.');
|
||||
setTimeout(displayData, 300000);
|
||||
return;
|
||||
}
|
||||
count++;
|
||||
|
||||
// specify user data to change:
|
||||
var set = {};
|
||||
var inc = {};
|
||||
inc = {
|
||||
'achievements.habiticaDays': 1,
|
||||
'items.food.Cake_Skeleton': 1,
|
||||
'items.food.Cake_Base': 1,
|
||||
'items.food.Cake_CottonCandyBlue': 1,
|
||||
'items.food.Cake_CottonCandyPink': 1,
|
||||
'items.food.Cake_Shade': 1,
|
||||
'items.food.Cake_White': 1,
|
||||
'items.food.Cake_Golden': 1,
|
||||
'items.food.Cake_Zombie': 1,
|
||||
'items.food.Cake_Desert': 1,
|
||||
'items.food.Cake_Red': 1
|
||||
};
|
||||
if (user.items.mounts['Gryphon-RoyalPurple']) {
|
||||
set = {'migration':migrationName, 'items.pets.Gryphon-RoyalPurple':5};
|
||||
} else {
|
||||
set = {'migration':migrationName, 'items.mounts.Gryphon-RoyalPurple':true};
|
||||
}
|
||||
|
||||
dbUsers.update({_id:user._id}, {$set:set, $inc:inc});
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
var migrationName = '20160731_takeThis.js';
|
||||
var authorName = 'Sabe'; // in case script author needs to know when their ...
|
||||
var authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; //... own data is done
|
||||
|
||||
/*
|
||||
* Award Take This Sword to Take This challenge participants who already own the Shield
|
||||
* and Take This Shield to the rest of the list
|
||||
*/
|
||||
|
||||
var mongo = require('mongoskin');
|
||||
|
||||
var connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
|
||||
|
||||
var dbUsers = mongo.db(connectionString).collection('users');
|
||||
|
||||
// specify a query to limit the affected users (empty for all users):
|
||||
var query = {
|
||||
'migration':{$ne:migrationName},
|
||||
'auth.timestamps.loggedin':{$gt:new Date('2016-07-30')}, // Extend timeframe each run of migration
|
||||
'challenges':{$in:['da8859b2-5c6e-4aa5-b8b2-8db93d5de9fc']}
|
||||
};
|
||||
|
||||
// specify fields we are interested in to limit retrieved data (empty if we're not reading data):
|
||||
var fields = {
|
||||
'items.gear.owned': 1
|
||||
};
|
||||
|
||||
console.warn('Updating users...');
|
||||
var progressCount = 1000;
|
||||
var count = 0;
|
||||
dbUsers.findEach(query, fields, {batchSize:250}, function(err, user) {
|
||||
if (err) { return exiting(1, 'ERROR! ' + err); }
|
||||
if (!user) {
|
||||
console.warn('All appropriate users found and modified.');
|
||||
setTimeout(displayData, 300000);
|
||||
return;
|
||||
}
|
||||
count++;
|
||||
|
||||
// specify user data to change:
|
||||
var set = {};
|
||||
|
||||
if (typeof user.items.gear.owned.shield_special_takeThis !== 'undefined') {
|
||||
set = {'migration':migrationName, 'items.gear.owned.weapon_special_takeThis':false};
|
||||
} else {
|
||||
set = {'migration':migrationName, 'items.gear.owned.shield_special_takeThis':false};
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
var migrationName = '20160831_takeThis.js';
|
||||
var authorName = 'Sabe'; // in case script author needs to know when their ...
|
||||
var authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; //... own data is done
|
||||
|
||||
/*
|
||||
* Award Take This Sword to Take This challenge participants who already own the Shield
|
||||
* and Take This Shield to the rest of the list
|
||||
*/
|
||||
|
||||
var mongo = require('mongoskin');
|
||||
|
||||
var connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
|
||||
|
||||
var dbUsers = mongo.db(connectionString).collection('users');
|
||||
|
||||
// specify a query to limit the affected users (empty for all users):
|
||||
var query = {
|
||||
'migration':{$ne:migrationName},
|
||||
'challenges':{$in:['ee2b3c87-13f0-422a-af3c-309102d4f7e6']}
|
||||
};
|
||||
|
||||
// specify fields we are interested in to limit retrieved data (empty if we're not reading data):
|
||||
var fields = {
|
||||
'items.gear.owned': 1
|
||||
};
|
||||
|
||||
console.warn('Updating users...');
|
||||
var progressCount = 1000;
|
||||
var count = 0;
|
||||
dbUsers.findEach(query, fields, {batchSize:250}, function(err, user) {
|
||||
if (err) { return exiting(1, 'ERROR! ' + err); }
|
||||
if (!user) {
|
||||
console.warn('All appropriate users found and modified.');
|
||||
setTimeout(displayData, 300000);
|
||||
return;
|
||||
}
|
||||
count++;
|
||||
|
||||
// specify user data to change:
|
||||
var set = {};
|
||||
|
||||
if (typeof user.items.gear.owned.weapon_special_takeThis !== 'undefined') {
|
||||
set = {'migration':migrationName, 'items.gear.owned.armor_special_takeThis':false};
|
||||
} else if (typeof user.items.gear.owned.shield_special_takeThis !== 'undefined') {
|
||||
set = {'migration':migrationName, 'items.gear.owned.weapon_special_takeThis':false};
|
||||
} else {
|
||||
set = {'migration':migrationName, 'items.gear.owned.shield_special_takeThis':false};
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
var migrationName = '20161002_takeThis.js';
|
||||
var authorName = 'Sabe'; // in case script author needs to know when their ...
|
||||
var authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; //... own data is done
|
||||
|
||||
/*
|
||||
* Award Take This ladder items to participants in this month's challenge
|
||||
*/
|
||||
|
||||
var mongo = require('mongoskin');
|
||||
|
||||
var connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
|
||||
|
||||
var dbUsers = mongo.db(connectionString).collection('users');
|
||||
|
||||
// specify a query to limit the affected users (empty for all users):
|
||||
var query = {
|
||||
'migration':{$ne:migrationName},
|
||||
'challenges':{$in:['4bbf63b5-10bc-49f9-8e95-5bd2ac99cd1c']}
|
||||
};
|
||||
|
||||
// specify fields we are interested in to limit retrieved data (empty if we're not reading data):
|
||||
var fields = {
|
||||
'items.gear.owned': 1
|
||||
};
|
||||
|
||||
console.warn('Updating users...');
|
||||
var progressCount = 1000;
|
||||
var count = 0;
|
||||
dbUsers.findEach(query, fields, {batchSize:250}, function(err, user) {
|
||||
if (err) { return exiting(1, 'ERROR! ' + err); }
|
||||
if (!user) {
|
||||
console.warn('All appropriate users found and modified.');
|
||||
setTimeout(displayData, 300000);
|
||||
return;
|
||||
}
|
||||
count++;
|
||||
|
||||
// specify user data to change:
|
||||
var set = {};
|
||||
|
||||
if (typeof user.items.gear.owned.armor_special_takeThis !== 'undefined') {
|
||||
set = {'migration':migrationName, 'items.gear.owned.head_special_takeThis':false};
|
||||
} else if (typeof user.items.gear.owned.weapon_special_takeThis !== 'undefined') {
|
||||
set = {'migration':migrationName, 'items.gear.owned.armor_special_takeThis':false};
|
||||
} else if (typeof user.items.gear.owned.shield_special_takeThis !== 'undefined') {
|
||||
set = {'migration':migrationName, 'items.gear.owned.weapon_special_takeThis':false};
|
||||
} else {
|
||||
set = {'migration':migrationName, 'items.gear.owned.shield_special_takeThis':false};
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
var migrationName = '20161030-jackolanterns.js';
|
||||
var authorName = 'Sabe'; // in case script author needs to know when their ...
|
||||
var authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; //... own data is done
|
||||
|
||||
/*
|
||||
* set the newStuff flag in all user accounts so they see a Bailey message
|
||||
*/
|
||||
|
||||
var mongo = require('mongoskin');
|
||||
|
||||
var connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
|
||||
|
||||
var dbUsers = mongo.db(connectionString).collection('users');
|
||||
|
||||
// specify a query to limit the affected users (empty for all users):
|
||||
var query = {
|
||||
'auth.timestamps.loggedin':{$gt:new Date('2016-10-01')} // remove when running migration a second time
|
||||
};
|
||||
|
||||
// specify fields we are interested in to limit retrieved data (empty if we're not reading data):
|
||||
var fields = {
|
||||
'migration': 1,
|
||||
'items.pets.JackOLantern-Base': 1,
|
||||
'items.mounts.JackOLantern-Base': 1,
|
||||
};
|
||||
|
||||
console.warn('Updating users...');
|
||||
var progressCount = 1000;
|
||||
var count = 0;
|
||||
dbUsers.findEach(query, fields, {batchSize:250}, function(err, user) {
|
||||
if (err) { return exiting(1, 'ERROR! ' + err); }
|
||||
if (!user) {
|
||||
console.warn('All appropriate users found and modified.');
|
||||
setTimeout(displayData, 300000);
|
||||
return;
|
||||
}
|
||||
count++;
|
||||
|
||||
// specify user data to change:
|
||||
var set = {};
|
||||
var inc = {};
|
||||
if (user.migration !== migrationName) {
|
||||
if (user.items.mounts['JackOLantern-Base']) {
|
||||
set = {'migration':migrationName, 'items.pets.JackOLantern-Ghost':5};
|
||||
} else if (user.items.pets['JackOLantern-Base']) {
|
||||
set = {'migration':migrationName, 'items.mounts.JackOLantern-Base':true};
|
||||
} else {
|
||||
set = {'migration':migrationName, 'items.pets.JackOLantern-Base':5};
|
||||
}
|
||||
inc = {
|
||||
'items.food.Candy_Base': 1,
|
||||
'items.food.Candy_CottonCandyBlue': 1,
|
||||
'items.food.Candy_CottonCandyPink': 1,
|
||||
'items.food.Candy_Desert': 1,
|
||||
'items.food.Candy_Golden': 1,
|
||||
'items.food.Candy_Red': 1,
|
||||
'items.food.Candy_Shade': 1,
|
||||
'items.food.Candy_Skeleton': 1,
|
||||
'items.food.Candy_White': 1,
|
||||
'items.food.Candy_Zombie': 1,
|
||||
}
|
||||
}
|
||||
|
||||
dbUsers.update({_id:user._id}, {$set:set, $inc:inc});
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
var migrationName = '20161102_takeThis.js';
|
||||
var authorName = 'Sabe'; // in case script author needs to know when their ...
|
||||
var authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; //... own data is done
|
||||
|
||||
/*
|
||||
* Award Take This ladder items to participants in this month's challenge
|
||||
*/
|
||||
|
||||
var mongo = require('mongoskin');
|
||||
|
||||
var connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
|
||||
|
||||
var dbUsers = mongo.db(connectionString).collection('users');
|
||||
|
||||
// specify a query to limit the affected users (empty for all users):
|
||||
var query = {
|
||||
'migration':{$ne:migrationName},
|
||||
'challenges':{$in:['d1be0965-e909-4d30-82fa-9a0011f885b2']}
|
||||
};
|
||||
|
||||
// specify fields we are interested in to limit retrieved data (empty if we're not reading data):
|
||||
var fields = {
|
||||
'items.gear.owned': 1
|
||||
};
|
||||
|
||||
console.warn('Updating users...');
|
||||
var progressCount = 1000;
|
||||
var count = 0;
|
||||
dbUsers.findEach(query, fields, {batchSize:250}, function(err, user) {
|
||||
if (err) { return exiting(1, 'ERROR! ' + err); }
|
||||
if (!user) {
|
||||
console.warn('All appropriate users found and modified.');
|
||||
setTimeout(displayData, 300000);
|
||||
return;
|
||||
}
|
||||
count++;
|
||||
|
||||
// specify user data to change:
|
||||
var set = {};
|
||||
|
||||
if (typeof user.items.gear.owned.head_special_takeThis !== 'undefined') {
|
||||
set = {'migration':migrationName, 'items.gear.owned.body_special_takeThis':false};
|
||||
} else if (typeof user.items.gear.owned.armor_special_takeThis !== 'undefined') {
|
||||
set = {'migration':migrationName, 'items.gear.owned.head_special_takeThis':false};
|
||||
} else if (typeof user.items.gear.owned.weapon_special_takeThis !== 'undefined') {
|
||||
set = {'migration':migrationName, 'items.gear.owned.armor_special_takeThis':false};
|
||||
} else if (typeof user.items.gear.owned.shield_special_takeThis !== 'undefined') {
|
||||
set = {'migration':migrationName, 'items.gear.owned.weapon_special_takeThis':false};
|
||||
} else {
|
||||
set = {'migration':migrationName, 'items.gear.owned.shield_special_takeThis':false};
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
var migrationName = '20161122_turkey_ladder.js';
|
||||
var authorName = 'Sabe'; // in case script author needs to know when their ...
|
||||
var authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; //... own data is done
|
||||
|
||||
/*
|
||||
* Yearly Turkey Day award. Turkey pet, Turkey mount, Gilded Turkey pet, Gilded Turkey mount
|
||||
*/
|
||||
|
||||
var mongo = require('mongoskin');
|
||||
|
||||
var connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
|
||||
|
||||
var dbUsers = mongo.db(connectionString).collection('users');
|
||||
|
||||
// specify a query to limit the affected users (empty for all users):
|
||||
var query = {
|
||||
'migration':{$ne:migrationName},
|
||||
'auth.timestamps.loggedin':{$gt:new Date('2016-10-31')} // Extend timeframe each run of migration
|
||||
};
|
||||
|
||||
// specify fields we are interested in to limit retrieved data (empty if we're not reading data):
|
||||
var fields = {
|
||||
'migration': 1,
|
||||
'items.mounts': 1,
|
||||
'items.pets': 1,
|
||||
};
|
||||
|
||||
console.warn('Updating users...');
|
||||
var progressCount = 1000;
|
||||
var count = 0;
|
||||
dbUsers.findEach(query, fields, {batchSize:250}, function(err, user) {
|
||||
if (err) { return exiting(1, 'ERROR! ' + err); }
|
||||
if (!user) {
|
||||
console.warn('All appropriate users found and modified.');
|
||||
setTimeout(displayData, 300000);
|
||||
return;
|
||||
}
|
||||
count++;
|
||||
|
||||
// specify user data to change:
|
||||
var set = {};
|
||||
|
||||
if (user.items.pets['Turkey-Gilded']) {
|
||||
set = {'migration':migrationName, 'items.mounts.Turkey-Gilded':true};
|
||||
} else if (user.items.mounts['Turkey-Base']) {
|
||||
set = {'migration':migrationName, 'items.pets.Turkey-Gilded':5};
|
||||
} else if (user.items.pets['Turkey-Base']) {
|
||||
set = {'migration':migrationName, 'items.mounts.Turkey-Base':true};
|
||||
} else {
|
||||
set = {'migration':migrationName, 'items.pets.Turkey-Base':5};
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
var migrationName = '20161230_nye_hats.js';
|
||||
var authorName = 'Sabe'; // in case script author needs to know when their ...
|
||||
var authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; //... own data is done
|
||||
|
||||
/*
|
||||
* Yearly New Year's party hat award
|
||||
*/
|
||||
|
||||
var mongo = require('mongoskin');
|
||||
|
||||
var connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
|
||||
|
||||
var dbUsers = mongo.db(connectionString).collection('users');
|
||||
|
||||
// specify a query to limit the affected users (empty for all users):
|
||||
var query = {
|
||||
'migration':{$ne:migrationName},
|
||||
'auth.timestamps.loggedin':{$gt:new Date('2016-11-30')} // Remove after first run
|
||||
};
|
||||
|
||||
// specify fields we are interested in to limit retrieved data (empty if we're not reading data):
|
||||
var fields = {
|
||||
'items.gear.owned': 1,
|
||||
};
|
||||
|
||||
console.warn('Updating users...');
|
||||
var progressCount = 1000;
|
||||
var count = 0;
|
||||
dbUsers.findEach(query, fields, {batchSize:250}, function(err, user) {
|
||||
if (err) { return exiting(1, 'ERROR! ' + err); }
|
||||
if (!user) {
|
||||
console.warn('All appropriate users found and modified.');
|
||||
setTimeout(displayData, 300000);
|
||||
return;
|
||||
}
|
||||
count++;
|
||||
|
||||
// specify user data to change:
|
||||
var set = {};
|
||||
|
||||
if (typeof user.items.gear.owned.head_special_nye2015 !== 'undefined') {
|
||||
set = {'migration':migrationName, 'items.gear.owned.head_special_nye2016':false};
|
||||
} else if (typeof user.items.gear.owned.head_special_nye2014 !== 'undefined') {
|
||||
set = {'migration':migrationName, 'items.gear.owned.head_special_nye2015':false};
|
||||
} else if (typeof user.items.gear.owned.head_special_nye !== 'undefined') {
|
||||
set = {'migration':migrationName, 'items.gear.owned.head_special_nye2014':false};
|
||||
} else {
|
||||
set = {'migration':migrationName, 'items.gear.owned.head_special_nye':false};
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user