mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 22:27:26 +01:00
fix linting of migrations
This commit is contained in:
11
.eslintrc
11
.eslintrc
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"root": true,
|
||||
"extends": [
|
||||
"habitrpg/lib/node"
|
||||
],
|
||||
"rules": {
|
||||
'no-param-reassign': ['error', {
|
||||
props: false,
|
||||
}],
|
||||
}
|
||||
}
|
||||
@@ -29,8 +29,8 @@ const testCount = (stdout, regexp) => {
|
||||
const testBin = (string, additionalEnvVariables = '') => {
|
||||
if (os.platform() === 'win32') {
|
||||
if (additionalEnvVariables !== '') {
|
||||
additionalEnvVariables = additionalEnvVariables.split(' ').join('&&set ');
|
||||
additionalEnvVariables = `set ${additionalEnvVariables}&&`;
|
||||
additionalEnvVariables = additionalEnvVariables.split(' ').join('&&set '); // eslint-disable-line no-param-reassign
|
||||
additionalEnvVariables = `set ${additionalEnvVariables}&&`; // eslint-disable-line no-param-reassign
|
||||
}
|
||||
return `set NODE_ENV=test&&${additionalEnvVariables}${string}`;
|
||||
}
|
||||
@@ -46,9 +46,9 @@ gulp.task('test:nodemon', gulp.series(done => {
|
||||
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.dropDatabase(err2 => {
|
||||
return mongoose.connection.dropDatabase(err2 => {
|
||||
if (err2) return cb(err2);
|
||||
mongoose.connection.close(cb);
|
||||
return mongoose.connection.close(cb);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -44,7 +44,7 @@ function eachTranslationFile (languages, cb) {
|
||||
const englishFile = fs.readFileSync(ENGLISH_LOCALE + filename);
|
||||
const parsedEnglishFile = JSON.parse(englishFile);
|
||||
|
||||
cb(null, lang, filename, parsedEnglishFile, parsedTranslationFile);
|
||||
return cb(null, lang, filename, parsedEnglishFile, parsedTranslationFile);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"root": false,
|
||||
"rules": {
|
||||
"no-console": 0,
|
||||
"no-use-before-define": ["error", { "functions": false }]
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ async function syncChallengeToMembers (challenges) {
|
||||
return Promise.all(promises);
|
||||
});
|
||||
|
||||
return await Promise.all(challengSyncPromises);
|
||||
return Promise.all(challengSyncPromises);
|
||||
}
|
||||
|
||||
async function syncChallenges (lastChallengeDate) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// mongo habitrpg ./node_modules/moment/moment.js ./migrations/cancelSubscription.js
|
||||
|
||||
// For some reason people often to contact me to cancel their sub, rather than do it online. Even when I point them to
|
||||
// For some reason people often to contact me to cancel their sub,
|
||||
// rather than do it online. Even when I point them to
|
||||
// the FAQ (http://goo.gl/1uoPGQ) they insist...
|
||||
|
||||
db.users.update(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Give contrib.level 7+ free subscription for life
|
||||
db.users.update(
|
||||
|
||||
{
|
||||
'contributor.level': { $gte: 7 },
|
||||
'purchased.plan.customerId': null,
|
||||
|
||||
@@ -84,7 +84,7 @@ db.users.aggregate([
|
||||
]).forEach(data => {
|
||||
// print( "\n" ); printjson(data);
|
||||
data.troublesomeIds.forEach(taskid => {
|
||||
print(`non-unique task: ${taskid}`);
|
||||
print(`non-unique task: ${taskid}`); // eslint-disable-line no-restricted-globals
|
||||
db.users.update({
|
||||
_id: uuid,
|
||||
todos: { $elemMatch: { id: taskid } },
|
||||
|
||||
@@ -4,6 +4,7 @@ const newUser = db.users.findOne({ _id: newId });
|
||||
|
||||
db.users.update({ _id: oldId }, { $set: { auth: newUser.auth } });
|
||||
|
||||
// remove the auth on the new user (which is a template account). The account will be preened automatically later,
|
||||
// remove the auth on the new user (which is a template account).
|
||||
// The account will be preened automatically later,
|
||||
// this allows us to keep the account around a few days in case there was a mistake
|
||||
db.users.update({ _id: newId }, { $unset: { auth: 1 } });
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/* let migrationName = 'Jackalopes for Unlimited Subscribers'; */
|
||||
|
||||
/*
|
||||
* This migration will find users with unlimited subscriptions who are also eligible for Jackalope mounts, and award them
|
||||
* This migration will find users with unlimited subscriptions who are also eligible
|
||||
* for Jackalope mounts, and award them
|
||||
*/
|
||||
|
||||
import { model as Group } from '../../website/server/models/group';
|
||||
@@ -35,7 +36,7 @@ async function handOutJackalopes () {
|
||||
|
||||
cursor.on('close', async () => {
|
||||
console.log('done');
|
||||
return await Promise.all(promises);
|
||||
return Promise.all(promises);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
import { model as Group } from '../../website/server/models/group';
|
||||
import { model as Chat } from '../../website/server/models/chat';
|
||||
import { chatModel as Chat } from '../../website/server/models/message';
|
||||
|
||||
async function moveGroupChatToModel (skip = 0) {
|
||||
const groups = await Group.find({})
|
||||
@@ -40,7 +40,7 @@ async function moveGroupChatToModel (skip = 0) {
|
||||
|
||||
|
||||
const reducedPromises = promises.reduce((acc, curr) => {
|
||||
acc = acc.concat(curr);
|
||||
acc = acc.concat(curr); // eslint-disable-line no-param-reassign
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import monk from 'monk';
|
||||
import monk from 'monk'; // eslint-disable-line import/no-extraneous-dependencies
|
||||
import nconf from 'nconf';
|
||||
import stripePayments from '../../website/server/libs/payments/stripe';
|
||||
|
||||
@@ -43,7 +43,7 @@ async function fixGroupPlanMembers () {
|
||||
},
|
||||
).each(async (group, { close, pause, resume }) => { // eslint-disable-line no-unused-vars
|
||||
pause();
|
||||
groupPlanCount++;
|
||||
groupPlanCount += 1;
|
||||
|
||||
const canonicalMemberCount = await dbUsers.count(
|
||||
{
|
||||
@@ -78,7 +78,7 @@ async function fixGroupPlanMembers () {
|
||||
|
||||
if (!groupUpdate) return;
|
||||
|
||||
fixedGroupCount++;
|
||||
fixedGroupCount += 1;
|
||||
if (group.purchased.plan.paymentMethod === 'Stripe') {
|
||||
await stripePayments.chargeForAdditionalGroupMember(group);
|
||||
await dbGroups.update(
|
||||
|
||||
@@ -5,12 +5,12 @@ let authorUuid = ''; // ... own data is done
|
||||
*/
|
||||
|
||||
/*
|
||||
* This migrations will iterate through all groups with a group plan a subscription and resync the free
|
||||
* subscription to all members
|
||||
* This migrations will iterate through all groups with a group plan
|
||||
* a subscription and resync the free subscription to all members
|
||||
*/
|
||||
|
||||
import { model as Group } from '../../website/server/models/group';
|
||||
import * as payments from '../../website/server/libs/payments';
|
||||
import payments from '../../website/server/libs/payments/payments';
|
||||
|
||||
async function updateGroupsWithGroupPlans () {
|
||||
const cursor = Group.find({
|
||||
@@ -25,7 +25,7 @@ async function updateGroupsWithGroupPlans () {
|
||||
promises.push(group.save());
|
||||
});
|
||||
|
||||
cursor.on('close', async () => await Promise.all(promises));
|
||||
cursor.on('close', async () => Promise.all(promises));
|
||||
}
|
||||
|
||||
module.exports = updateGroupsWithGroupPlans;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
require('babel-register');
|
||||
require('@babel/register'); // eslint-disable-line import/no-extraneous-dependencies
|
||||
|
||||
// This file must use ES5, everything required can be in ES6
|
||||
|
||||
@@ -17,7 +17,7 @@ function setUpServer () {
|
||||
setUpServer();
|
||||
|
||||
// Replace this with your migration
|
||||
const processUsers = require('');
|
||||
const processUsers = () => {}; // require('');
|
||||
|
||||
processUsers()
|
||||
.then(() => {
|
||||
|
||||
@@ -6,7 +6,7 @@ const authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; // ... own data is do
|
||||
* set the newStuff flag in all user accounts so they see a Bailey message
|
||||
*/
|
||||
|
||||
const monk = require('monk');
|
||||
const monk = require('monk'); // eslint-disable-line import/no-extraneous-dependencies
|
||||
|
||||
const connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
|
||||
const dbUsers = monk(connectionString).get('users', { castIds: false });
|
||||
@@ -26,7 +26,9 @@ function processUsers (lastId) {
|
||||
dbUsers.find(query, {
|
||||
sort: { _id: 1 },
|
||||
limit: 250,
|
||||
fields: [], // specify fields we are interested in to limit retrieved data (empty if we're not reading data):
|
||||
// specify fields we are interested in to limit retrieved data
|
||||
// (empty if we're not reading data):
|
||||
fields: [],
|
||||
})
|
||||
.then(updateUsers)
|
||||
.catch(err => {
|
||||
@@ -42,7 +44,7 @@ function updateUsers (users) {
|
||||
if (!users || users.length === 0) {
|
||||
console.warn('All appropriate users found and modified.');
|
||||
displayData();
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
const userPromises = users.map(updateUser);
|
||||
@@ -55,7 +57,7 @@ function updateUsers (users) {
|
||||
}
|
||||
|
||||
function updateUser (user) {
|
||||
count++;
|
||||
count += 1;
|
||||
|
||||
const set = { 'flags.newStuff': true };
|
||||
|
||||
@@ -71,9 +73,10 @@ function displayData () {
|
||||
}
|
||||
|
||||
function exiting (code, msg) {
|
||||
code = code || 0; // 0 = success
|
||||
// 0 = success
|
||||
code = code || 0; // eslint-disable-line no-param-reassign
|
||||
if (code && !msg) {
|
||||
msg = 'ERROR!';
|
||||
msg = 'ERROR!'; // eslint-disable-line no-param-reassign
|
||||
}
|
||||
if (msg) {
|
||||
if (code) {
|
||||
|
||||
@@ -6,7 +6,7 @@ const authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; // ... own data is do
|
||||
* Remove flag stating that the Enchanted Armoire is empty, for when new equipment is added
|
||||
*/
|
||||
|
||||
const monk = require('monk');
|
||||
const monk = require('monk'); // eslint-disable-line import/no-extraneous-dependencies
|
||||
|
||||
const connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
|
||||
const dbUsers = monk(connectionString).get('users', { castIds: false });
|
||||
@@ -26,7 +26,9 @@ function processUsers (lastId) {
|
||||
dbUsers.find(query, {
|
||||
sort: { _id: 1 },
|
||||
limit: 250,
|
||||
fields: [], // specify fields we are interested in to limit retrieved data (empty if we're not reading data):
|
||||
// specify fields we are interested in to limit retrieved data
|
||||
// (empty if we're not reading data):
|
||||
fields: [],
|
||||
})
|
||||
.then(updateUsers)
|
||||
.catch(err => {
|
||||
@@ -42,7 +44,7 @@ function updateUsers (users) {
|
||||
if (!users || users.length === 0) {
|
||||
console.warn('All appropriate users found and modified.');
|
||||
displayData();
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
const userPromises = users.map(updateUser);
|
||||
@@ -55,7 +57,7 @@ function updateUsers (users) {
|
||||
}
|
||||
|
||||
function updateUser (user) {
|
||||
count++;
|
||||
count += 1;
|
||||
|
||||
const set = { migration: migrationName, 'flags.armoireEmpty': false };
|
||||
|
||||
@@ -71,9 +73,10 @@ function displayData () {
|
||||
}
|
||||
|
||||
function exiting (code, msg) {
|
||||
code = code || 0; // 0 = success
|
||||
// 0 = success
|
||||
code = code || 0; // eslint-disable-line no-param-reassign
|
||||
if (code && !msg) {
|
||||
msg = 'ERROR!';
|
||||
msg = 'ERROR!'; // eslint-disable-line no-param-reassign
|
||||
}
|
||||
if (msg) {
|
||||
if (code) {
|
||||
|
||||
@@ -20,7 +20,7 @@ const authorUuid = '3e595299-3d8a-4a10-bfe0-88f555e4aa0c'; // ... own data is do
|
||||
|
||||
const connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
|
||||
|
||||
const monk = require('monk');
|
||||
const monk = require('monk'); // eslint-disable-line import/no-extraneous-dependencies
|
||||
|
||||
const dbUsers = monk(connectionString).get('users', { castIds: false });
|
||||
|
||||
@@ -47,10 +47,12 @@ function processUsers (lastId) {
|
||||
dbUsers.find(query, {
|
||||
sort: { _id: 1 },
|
||||
limit: 250,
|
||||
// specify fields we are interested in to limit retrieved data
|
||||
// (empty if we're not reading data):
|
||||
fields: {
|
||||
'flags.armoireEmpty': 1,
|
||||
'items.gear.owned': 1,
|
||||
}, // specify fields we are interested in to limit retrieved data (empty if we're not reading data):
|
||||
},
|
||||
})
|
||||
.then(updateUsers)
|
||||
.catch(err => {
|
||||
@@ -66,7 +68,7 @@ function updateUsers (users) {
|
||||
if (!users || users.length === 0) {
|
||||
console.warn('All appropriate users found and modified.');
|
||||
displayData();
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
const userPromises = users.map(updateUser);
|
||||
@@ -79,14 +81,64 @@ function updateUsers (users) {
|
||||
}
|
||||
|
||||
function updateUser (user) {
|
||||
count++;
|
||||
count += 1;
|
||||
|
||||
const set = { migration: migrationName, 'flags.armoireEmpty': false };
|
||||
|
||||
|
||||
if (user.flags.armoireEmpty) {
|
||||
// this user believes their armoire has no more items in it
|
||||
if (user.items.gear.owned.weapon_armoire_barristerGavel && user.items.gear.owned.armor_armoire_barristerRobes && user.items.gear.owned.head_armoire_jesterCap && user.items.gear.owned.armor_armoire_jesterCostume && user.items.gear.owned.head_armoire_barristerWig && user.items.gear.owned.weapon_armoire_jesterBaton && user.items.gear.owned.weapon_armoire_lunarSceptre && user.items.gear.owned.armor_armoire_gladiatorArmor && user.items.gear.owned.weapon_armoire_basicCrossbow && user.items.gear.owned.head_armoire_gladiatorHelm && user.items.gear.owned.armor_armoire_lunarArmor && user.items.gear.owned.head_armoire_redHairbow && user.items.gear.owned.head_armoire_violetFloppyHat && user.items.gear.owned.head_armoire_rancherHat && user.items.gear.owned.shield_armoire_gladiatorShield && user.items.gear.owned.head_armoire_blueHairbow && user.items.gear.owned.weapon_armoire_mythmakerSword && user.items.gear.owned.head_armoire_royalCrown && user.items.gear.owned.head_armoire_hornedIronHelm && user.items.gear.owned.weapon_armoire_rancherLasso && user.items.gear.owned.armor_armoire_rancherRobes && user.items.gear.owned.armor_armoire_hornedIronArmor && user.items.gear.owned.armor_armoire_goldenToga && user.items.gear.owned.weapon_armoire_ironCrook && user.items.gear.owned.head_armoire_goldenLaurels && user.items.gear.owned.head_armoire_redFloppyHat && user.items.gear.owned.armor_armoire_plagueDoctorOvercoat && user.items.gear.owned.head_armoire_plagueDoctorHat && user.items.gear.owned.weapon_armoire_goldWingStaff && user.items.gear.owned.head_armoire_yellowHairbow && user.items.gear.owned.eyewear_armoire_plagueDoctorMask && user.items.gear.owned.head_armoire_blackCat && user.items.gear.owned.weapon_armoire_batWand && user.items.gear.owned.head_armoire_orangeCat && user.items.gear.owned.shield_armoire_midnightShield && user.items.gear.owned.armor_armoire_royalRobes && user.items.gear.owned.head_armoire_blueFloppyHat && user.items.gear.owned.shield_armoire_royalCane && user.items.gear.owned.weapon_armoire_shepherdsCrook && user.items.gear.owned.armor_armoire_shepherdRobes && user.items.gear.owned.head_armoire_shepherdHeaddress && user.items.gear.owned.weapon_armoire_blueLongbow && user.items.gear.owned.weapon_armoire_crystalCrescentStaff && user.items.gear.owned.head_armoire_crystalCrescentHat && user.items.gear.owned.armor_armoire_dragonTamerArmor && user.items.gear.owned.head_armoire_dragonTamerHelm && user.items.gear.owned.armor_armoire_crystalCrescentRobes && user.items.gear.owned.shield_armoire_dragonTamerShield && user.items.gear.owned.weapon_armoire_glowingSpear) {
|
||||
if (
|
||||
user.items.gear.owned.weapon_armoire_barristerGavel
|
||||
&& user.items.gear.owned.armor_armoire_barristerRobes
|
||||
&& user.items.gear.owned.head_armoire_jesterCap
|
||||
&& user.items.gear.owned.armor_armoire_jesterCostume
|
||||
&& user.items.gear.owned.head_armoire_barristerWig
|
||||
&& user.items.gear.owned.weapon_armoire_jesterBaton
|
||||
&& user.items.gear.owned.weapon_armoire_lunarSceptre
|
||||
&& user.items.gear.owned.armor_armoire_gladiatorArmor
|
||||
&& user.items.gear.owned.weapon_armoire_basicCrossbow
|
||||
&& user.items.gear.owned.head_armoire_gladiatorHelm
|
||||
&& user.items.gear.owned.armor_armoire_lunarArmor
|
||||
&& user.items.gear.owned.head_armoire_redHairbow
|
||||
&& user.items.gear.owned.head_armoire_violetFloppyHat
|
||||
&& user.items.gear.owned.head_armoire_rancherHat
|
||||
&& user.items.gear.owned.shield_armoire_gladiatorShield
|
||||
&& user.items.gear.owned.head_armoire_blueHairbow
|
||||
&& user.items.gear.owned.weapon_armoire_mythmakerSword
|
||||
&& user.items.gear.owned.head_armoire_royalCrown
|
||||
&& user.items.gear.owned.head_armoire_hornedIronHelm
|
||||
&& user.items.gear.owned.weapon_armoire_rancherLasso
|
||||
&& user.items.gear.owned.armor_armoire_rancherRobes
|
||||
&& user.items.gear.owned.armor_armoire_hornedIronArmor
|
||||
&& user.items.gear.owned.armor_armoire_goldenToga
|
||||
&& user.items.gear.owned.weapon_armoire_ironCrook
|
||||
&& user.items.gear.owned.head_armoire_goldenLaurels
|
||||
&& user.items.gear.owned.head_armoire_redFloppyHat
|
||||
&& user.items.gear.owned.armor_armoire_plagueDoctorOvercoat
|
||||
&& user.items.gear.owned.head_armoire_plagueDoctorHat
|
||||
&& user.items.gear.owned.weapon_armoire_goldWingStaff
|
||||
&& user.items.gear.owned.head_armoire_yellowHairbow
|
||||
&& user.items.gear.owned.eyewear_armoire_plagueDoctorMask
|
||||
&& user.items.gear.owned.head_armoire_blackCat
|
||||
&& user.items.gear.owned.weapon_armoire_batWand
|
||||
&& user.items.gear.owned.head_armoire_orangeCat
|
||||
&& user.items.gear.owned.shield_armoire_midnightShield
|
||||
&& user.items.gear.owned.armor_armoire_royalRobes
|
||||
&& user.items.gear.owned.head_armoire_blueFloppyHat
|
||||
&& user.items.gear.owned.shield_armoire_royalCane
|
||||
&& user.items.gear.owned.weapon_armoire_shepherdsCrook
|
||||
&& user.items.gear.owned.armor_armoire_shepherdRobes
|
||||
&& user.items.gear.owned.head_armoire_shepherdHeaddress
|
||||
&& user.items.gear.owned.weapon_armoire_blueLongbow
|
||||
&& user.items.gear.owned.weapon_armoire_crystalCrescentStaff
|
||||
&& user.items.gear.owned.head_armoire_crystalCrescentHat
|
||||
&& user.items.gear.owned.armor_armoire_dragonTamerArmor
|
||||
&& user.items.gear.owned.head_armoire_dragonTamerHelm
|
||||
&& user.items.gear.owned.armor_armoire_crystalCrescentRobes
|
||||
&& user.items.gear.owned.shield_armoire_dragonTamerShield
|
||||
&& user.items.gear.owned.weapon_armoire_glowingSpear
|
||||
) {
|
||||
// this user does have all the armoire items so we don't change the flag
|
||||
// console.log("don't change: " + user._id); // FOR TESTING
|
||||
} else {
|
||||
@@ -109,9 +161,10 @@ function displayData () {
|
||||
}
|
||||
|
||||
function exiting (code, msg) {
|
||||
code = code || 0; // 0 = success
|
||||
// 0 = success
|
||||
code = code || 0; // eslint-disable-line no-param-reassign
|
||||
if (code && !msg) {
|
||||
msg = 'ERROR!';
|
||||
msg = 'ERROR!'; // eslint-disable-line no-param-reassign
|
||||
}
|
||||
if (msg) {
|
||||
if (code) {
|
||||
|
||||
@@ -6,12 +6,12 @@ const authorUuid = ''; // ... own data is done
|
||||
* Check if users have empty profile data in new database and update it with old database info
|
||||
*/
|
||||
|
||||
const monk = require('monk');
|
||||
const monk = require('monk'); // eslint-disable-line import/no-extraneous-dependencies
|
||||
|
||||
const connectionString = ''; // FOR TEST DATABASE
|
||||
const dbUsers = monk(connectionString).get('users', { castIds: false });
|
||||
|
||||
const monk2 = require('monk');
|
||||
const monk2 = require('monk'); // eslint-disable-line import/no-extraneous-dependencies
|
||||
|
||||
const oldDbConnectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
|
||||
const olDbUsers = monk2(oldDbConnectionString).get('users', { castIds: false });
|
||||
@@ -49,7 +49,7 @@ function updateUsers (users) {
|
||||
if (!users || users.length === 0) {
|
||||
console.warn('All appropriate users found and modified.');
|
||||
setTimeout(displayData, 300000);
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
const userPaymentPromises = users.map(updateUser);
|
||||
@@ -60,16 +60,16 @@ function updateUsers (users) {
|
||||
}
|
||||
|
||||
function updateUser (user) {
|
||||
count++;
|
||||
count += 1;
|
||||
|
||||
if (!user.profile.name || user.profile.name === 'profile name not found' || !user.profile.imageUrl || !user.profile.blurb) {
|
||||
return olDbUsers.findOne({ _id: user._id }, '_id profile')
|
||||
.then(oldUserData => {
|
||||
if (!oldUserData) return;
|
||||
if (!oldUserData) return null;
|
||||
// specify user data to change:
|
||||
const set = {};
|
||||
|
||||
if (oldUserData.profile.name === 'profile name not found') return;
|
||||
if (oldUserData.profile.name === 'profile name not found') return null;
|
||||
|
||||
const userNeedsProfileName = !user.profile.name || user.profile.name === 'profile name not found';
|
||||
if (userNeedsProfileName && oldUserData.profile.name) {
|
||||
@@ -88,11 +88,15 @@ function updateUser (user) {
|
||||
console.log(set);
|
||||
return dbUsers.update({ _id: user._id }, { $set: set });
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
if (count % progressCount === 0) console.warn(`${count} ${user._id}`);
|
||||
if (user._id === authorUuid) console.warn(`${authorName} processed`);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function displayData () {
|
||||
@@ -101,9 +105,10 @@ function displayData () {
|
||||
}
|
||||
|
||||
function exiting (code, msg) {
|
||||
code = code || 0; // 0 = success
|
||||
// 0 = success
|
||||
code = code || 0; // eslint-disable-line no-param-reassign
|
||||
if (code && !msg) {
|
||||
msg = 'ERROR!';
|
||||
msg = 'ERROR!'; // eslint-disable-line no-param-reassign
|
||||
}
|
||||
if (msg) {
|
||||
if (code) {
|
||||
|
||||
@@ -46,7 +46,7 @@ function getFileFromUrl (url) {
|
||||
request.get(url).end((err, res) => {
|
||||
if (err) return reject(err);
|
||||
const file = res.body;
|
||||
resolve(file);
|
||||
return resolve(file);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -70,7 +70,7 @@ function uploadToS3 (start, end, filesUrls) {
|
||||
.then(buffer => uploadFile(buffer, getFileName(fullUrl))));
|
||||
console.log(promises.length);
|
||||
|
||||
return Promise.all(promises)
|
||||
Promise.all(promises)
|
||||
.then(() => {
|
||||
currentIndex += 50;
|
||||
uploadToS3(currentIndex, currentIndex + 50, filesUrls);
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
// const authorUuid = 'ed4c688c-6652-4a92-9d03-a5a79844174a'; // ... own data is done
|
||||
|
||||
/*
|
||||
* Iterates over all habits and condense multiple history entries for the same day into a single entry
|
||||
* Iterates over all habits and condense multiple history entries for the same day into a single one
|
||||
*/
|
||||
|
||||
const monk = require('monk');
|
||||
const monk = require('monk'); // eslint-disable-line import/no-extraneous-dependencies
|
||||
const _ = require('lodash');
|
||||
const moment = require('moment');
|
||||
|
||||
@@ -44,7 +44,7 @@ function updateChallengeHabits (habits) {
|
||||
if (!habits || habits.length === 0) {
|
||||
console.warn('All appropriate challenge habits found and modified.');
|
||||
displayData();
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
const habitsPromises = habits.map(updateChallengeHabit);
|
||||
@@ -55,7 +55,7 @@ function updateChallengeHabits (habits) {
|
||||
}
|
||||
|
||||
function updateChallengeHabit (habit) {
|
||||
count++;
|
||||
count += 1;
|
||||
|
||||
if (habit && habit.history && habit.history.length > 0) {
|
||||
// First remove missing entries
|
||||
@@ -75,8 +75,8 @@ function updateChallengeHabit (habit) {
|
||||
entry.scoreDirection = entry.value > previousValue ? 'up' : 'down';
|
||||
}
|
||||
})
|
||||
.groupBy(entry => // group entries by aggregateBy
|
||||
moment(entry.date).format('YYYYMMDD'))
|
||||
// group entries by aggregateBy
|
||||
.groupBy(entry => moment(entry.date).format('YYYYMMDD'))
|
||||
.toPairs() // [key, entry]
|
||||
.sortBy(([key]) => key) // sort by date
|
||||
.map(keyEntryPair => {
|
||||
@@ -111,6 +111,7 @@ function updateChallengeHabit (habit) {
|
||||
}
|
||||
|
||||
if (count % progressCount === 0) console.warn(`${count} habits processed`);
|
||||
return null;
|
||||
}
|
||||
|
||||
function displayData () {
|
||||
@@ -119,9 +120,10 @@ function displayData () {
|
||||
}
|
||||
|
||||
function exiting (code, msg) {
|
||||
code = code || 0; // 0 = success
|
||||
// 0 = success
|
||||
code = code || 0; // eslint-disable-line no-param-reassign
|
||||
if (code && !msg) {
|
||||
msg = 'ERROR!';
|
||||
msg = 'ERROR!'; // eslint-disable-line no-param-reassign
|
||||
}
|
||||
if (msg) {
|
||||
if (code) {
|
||||
|
||||
@@ -3,10 +3,10 @@ const authorName = 'paglias'; // in case script author needs to know when their
|
||||
const authorUuid = 'ed4c688c-6652-4a92-9d03-a5a79844174a'; // ... own data is done
|
||||
|
||||
/*
|
||||
* Iterates over all habits and condense multiple history entries for the same day into a single entry
|
||||
* Iterates over all habits and condense multiple history entries for the same day into a single one
|
||||
*/
|
||||
|
||||
const monk = require('monk');
|
||||
const monk = require('monk'); // eslint-disable-line import/no-extraneous-dependencies
|
||||
const _ = require('lodash');
|
||||
const moment = require('moment');
|
||||
|
||||
@@ -44,7 +44,7 @@ function updateUsers (users) {
|
||||
if (!users || users.length === 0) {
|
||||
console.warn('All appropriate users and their tasks found and modified.');
|
||||
displayData();
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
const usersPromises = users.map(updateUser);
|
||||
@@ -110,10 +110,12 @@ function updateHabit (habit, timezoneOffset, dayStart) {
|
||||
$set: { history: habit.history },
|
||||
});
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function updateUser (user) {
|
||||
count++;
|
||||
count += 1;
|
||||
|
||||
const { timezoneOffset } = user.preferences;
|
||||
const { dayStart } = user.preferences;
|
||||
@@ -141,9 +143,10 @@ function displayData () {
|
||||
}
|
||||
|
||||
function exiting (code, msg) {
|
||||
code = code || 0; // 0 = success
|
||||
// 0 = success
|
||||
code = code || 0; // eslint-disable-line no-param-reassign
|
||||
if (code && !msg) {
|
||||
msg = 'ERROR!';
|
||||
msg = 'ERROR!'; // eslint-disable-line no-param-reassign
|
||||
}
|
||||
if (msg) {
|
||||
if (code) {
|
||||
|
||||
@@ -3,10 +3,11 @@ const authorName = 'Sabe'; // in case script author needs to know when their ...
|
||||
const authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; // ... own data is done
|
||||
|
||||
/*
|
||||
* Iterates over all tasks and sets invalid everyX values (less than 0 or more than 9999 or not an int) field to 0
|
||||
* Iterates over all tasks and sets invalid everyX values
|
||||
* (less than 0 or more than 9999 or not an int) field to 0
|
||||
*/
|
||||
|
||||
const monk = require('monk');
|
||||
const monk = require('monk'); // eslint-disable-line import/no-extraneous-dependencies
|
||||
|
||||
const connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true';
|
||||
const dbTasks = monk(connectionString).get('tasks', { castIds: false });
|
||||
@@ -49,7 +50,7 @@ function updateTasks (tasks) {
|
||||
if (!tasks || tasks.length === 0) {
|
||||
console.warn('All appropriate tasks found and modified.');
|
||||
displayData();
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
const taskPromises = tasks.map(updatetask);
|
||||
@@ -60,7 +61,7 @@ function updateTasks (tasks) {
|
||||
}
|
||||
|
||||
function updatetask (task) {
|
||||
count++;
|
||||
count += 1;
|
||||
const set = { everyX: 0 };
|
||||
|
||||
dbTasks.update({ _id: task._id }, { $set: set });
|
||||
@@ -75,9 +76,10 @@ function displayData () {
|
||||
}
|
||||
|
||||
function exiting (code, msg) {
|
||||
code = code || 0; // 0 = success
|
||||
// 0 = success
|
||||
code = code || 0; // eslint-disable-line no-param-reassign
|
||||
if (code && !msg) {
|
||||
msg = 'ERROR!';
|
||||
msg = 'ERROR!'; // eslint-disable-line no-param-reassign
|
||||
}
|
||||
if (msg) {
|
||||
if (code) {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Iterates over all tasks and sets the yseterDaily field to True
|
||||
*/
|
||||
|
||||
import monk from 'monk';
|
||||
import monk from 'monk'; // eslint-disable-line import/no-extraneous-dependencies
|
||||
|
||||
const authorName = 'TheHollidayInn'; // in case script author needs to know when their ...
|
||||
const authorUuid = '';
|
||||
@@ -17,9 +17,10 @@ const progressCount = 1000;
|
||||
let count = 0;
|
||||
|
||||
function exiting (code, msg) {
|
||||
code = code || 0; // 0 = success
|
||||
// 0 = success
|
||||
code = code || 0; // eslint-disable-line no-param-reassign
|
||||
if (code && !msg) {
|
||||
msg = 'ERROR!';
|
||||
msg = 'ERROR!'; // eslint-disable-line no-param-reassign
|
||||
}
|
||||
if (msg) {
|
||||
if (code) {
|
||||
@@ -37,7 +38,7 @@ function displayData () {
|
||||
}
|
||||
|
||||
function updatetask (task) {
|
||||
count++;
|
||||
count += 1;
|
||||
const set = { yesterDaily: true };
|
||||
|
||||
dbTasks.update({ _id: task._id }, { $set: set });
|
||||
@@ -50,15 +51,14 @@ function updateTasks (tasks) {
|
||||
if (!tasks || tasks.length === 0) {
|
||||
console.warn('All appropriate tasks found and modified.');
|
||||
displayData();
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
const taskPromises = tasks.map(updatetask);
|
||||
const lasttask = tasks[tasks.length - 1];
|
||||
|
||||
return Promise.all(taskPromises)
|
||||
.then(() => processTasks(lasttask._id), // eslint-disable-line no-use-before-define
|
||||
);
|
||||
.then(() => processTasks(lasttask._id)); // eslint-disable-line no-use-before-define
|
||||
}
|
||||
|
||||
function processTasks (lastId) {
|
||||
@@ -76,7 +76,9 @@ function processTasks (lastId) {
|
||||
dbTasks.find(query, {
|
||||
sort: { _id: 1 },
|
||||
limit: 250,
|
||||
fields: [ // specify fields we are interested in to limit retrieved data (empty if we're not reading data):
|
||||
// specify fields we are interested in to limit retrieved data
|
||||
// (empty if we're not reading data):
|
||||
fields: [
|
||||
],
|
||||
})
|
||||
.then(updateTasks)
|
||||
|
||||
@@ -8,7 +8,7 @@ let authorUuid = ''; // ... own data is done
|
||||
* This migraition will copy user data from prod to test
|
||||
*/
|
||||
|
||||
const monk = require('monk');
|
||||
const monk = require('monk'); // eslint-disable-line import/no-extraneous-dependencies
|
||||
|
||||
const connectionString = '';
|
||||
const Users = monk(connectionString).get('users', { castIds: false });
|
||||
|
||||
@@ -8,7 +8,7 @@ const authorUuid = ''; // ... own data is done
|
||||
* This migraition will copy user data from prod to test
|
||||
*/
|
||||
|
||||
const monk = require('monk');
|
||||
const monk = require('monk'); // eslint-disable-line import/no-extraneous-dependencies
|
||||
|
||||
const connectionString = 'mongodb://localhost/new-habit';
|
||||
const Users = monk(connectionString).get('users', { castIds: false });
|
||||
@@ -26,9 +26,11 @@ function getAchievementUpdate (newUser, oldUser) {
|
||||
if (!achievementsUpdate.ultimateGearSets && oldAchievements.ultimateGearSets) {
|
||||
achievementsUpdate.ultimateGearSets = oldAchievements.ultimateGearSets;
|
||||
} else if (oldAchievements.ultimateGearSets) {
|
||||
for (const index in oldAchievements.ultimateGearSets) {
|
||||
if (oldAchievements.ultimateGearSets[index]) achievementsUpdate.ultimateGearSets[index] = true;
|
||||
Object.keys(oldAchievements.ultimateGearSets).forEach(index => {
|
||||
if (oldAchievements.ultimateGearSets[index]) {
|
||||
achievementsUpdate.ultimateGearSets[index] = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// challenges
|
||||
@@ -38,35 +40,37 @@ function getAchievementUpdate (newUser, oldUser) {
|
||||
|
||||
// Quests
|
||||
if (!achievementsUpdate.quests) achievementsUpdate.quests = {};
|
||||
for (const index in oldAchievements.quests) {
|
||||
Object.keys(oldAchievements.quests).forEach(index => {
|
||||
if (!achievementsUpdate.quests[index]) {
|
||||
achievementsUpdate.quests[index] = oldAchievements.quests[index];
|
||||
} else {
|
||||
achievementsUpdate.quests[index] += oldAchievements.quests[index];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Rebirth level
|
||||
if (achievementsUpdate.rebirthLevel) {
|
||||
achievementsUpdate.rebirthLevel = Math.max(achievementsUpdate.rebirthLevel, oldAchievements.rebirthLevel);
|
||||
achievementsUpdate.rebirthLevel = Math.max(
|
||||
achievementsUpdate.rebirthLevel, oldAchievements.rebirthLevel,
|
||||
);
|
||||
} else if (oldAchievements.rebirthLevel) {
|
||||
achievementsUpdate.rebirthLevel = oldAchievements.rebirthLevel;
|
||||
}
|
||||
|
||||
// All others
|
||||
const indexsToIgnore = ['ultimateGearSets', 'challenges', 'quests', 'rebirthLevel'];
|
||||
for (const index in oldAchievements) {
|
||||
if (indexsToIgnore.indexOf(index) !== -1) continue; // eslint-disable-line no-continue
|
||||
Object.keys(oldAchievements).forEach(index => {
|
||||
if (indexsToIgnore.indexOf(index) !== -1) return;
|
||||
|
||||
if (!achievementsUpdate[index]) {
|
||||
achievementsUpdate[index] = oldAchievements[index];
|
||||
continue; // eslint-disable-line no-continue
|
||||
return;
|
||||
}
|
||||
|
||||
if (Number.isInteger(oldAchievements[index])) {
|
||||
achievementsUpdate[index] += oldAchievements[index];
|
||||
} else if (oldAchievements[index] === true) achievementsUpdate[index] = true;
|
||||
}
|
||||
});
|
||||
|
||||
return achievementsUpdate;
|
||||
}
|
||||
@@ -75,9 +79,7 @@ module.exports = async function achievementRestore () {
|
||||
const userIds = [
|
||||
];
|
||||
|
||||
/* eslint-disable no-await-in-loop */
|
||||
for (const index in userIds) {
|
||||
const userId = userIds[index];
|
||||
Promise.all(userIds.map(userId => (async () => {
|
||||
const oldUser = await UsersOld.findOne({ _id: userId }, 'achievements');
|
||||
const newUser = await Users.findOne({ _id: userId }, 'achievements');
|
||||
const achievementUpdate = getAchievementUpdate(newUser, oldUser);
|
||||
@@ -90,6 +92,5 @@ module.exports = async function achievementRestore () {
|
||||
},
|
||||
);
|
||||
console.log(`Updated ${userId}`);
|
||||
/* eslint-enable no-await-in-loop */
|
||||
}
|
||||
})()));
|
||||
};
|
||||
|
||||
@@ -12,7 +12,7 @@ const progressCount = 1000;
|
||||
let count = 0;
|
||||
|
||||
async function updateUser (user) {
|
||||
count++;
|
||||
count += 1;
|
||||
|
||||
if (count % progressCount === 0) console.warn(`${count} ${user._id}`);
|
||||
|
||||
@@ -22,7 +22,7 @@ async function updateUser (user) {
|
||||
[{ name: 'BASE_URL', content: BASE_URL }], // Add variables from template
|
||||
);
|
||||
|
||||
return await User.update({ _id: user._id }, { $set: { migration: MIGRATION_NAME } }).exec();
|
||||
return User.update({ _id: user._id }, { $set: { migration: MIGRATION_NAME } }).exec();
|
||||
}
|
||||
|
||||
module.exports = async function processUsers () {
|
||||
|
||||
@@ -15,7 +15,7 @@ let count = 0;
|
||||
*/
|
||||
|
||||
async function updateUser (user) {
|
||||
count++;
|
||||
count += 1;
|
||||
|
||||
const set = {};
|
||||
|
||||
@@ -48,7 +48,7 @@ async function updateUser (user) {
|
||||
|
||||
if (count % progressCount === 0) console.warn(`${count} ${user._id}`);
|
||||
|
||||
return await User.update({ _id: user._id }, { $set: set }).exec();
|
||||
return User.update({ _id: user._id }, { $set: set }).exec();
|
||||
}
|
||||
|
||||
module.exports = async function processUsers () {
|
||||
|
||||
@@ -9,7 +9,7 @@ const progressCount = 1000;
|
||||
let count = 0;
|
||||
|
||||
async function updateUser (user) {
|
||||
count++;
|
||||
count += 1;
|
||||
|
||||
const addToSet = {
|
||||
'purchased.plan.mysteryItems': {
|
||||
@@ -30,7 +30,7 @@ async function updateUser (user) {
|
||||
|
||||
if (count % progressCount === 0) console.warn(`${count} ${user._id}`);
|
||||
|
||||
return await User.update({ _id: user._id }, { $set: set, $push: push, $addToSet: addToSet }).exec();
|
||||
return User.update({ _id: user._id }, { $set: set, $push: push, $addToSet: addToSet }).exec();
|
||||
}
|
||||
|
||||
module.exports = async function processUsers () {
|
||||
|
||||
@@ -9,7 +9,7 @@ const progressCount = 1000;
|
||||
let count = 0;
|
||||
|
||||
async function updateUser (user) {
|
||||
count++;
|
||||
count *= 1;
|
||||
|
||||
const inc = {
|
||||
'items.food.Pie_Skeleton': 1,
|
||||
@@ -36,7 +36,9 @@ async function updateUser (user) {
|
||||
|
||||
if (count % progressCount === 0) console.warn(`${count} ${user._id}`);
|
||||
|
||||
return await User.update({ _id: user._id }, { $inc: inc, $set: set, $push: { pinnedItems: { $each: push } } }).exec();
|
||||
return User
|
||||
.update({ _id: user._id }, { $inc: inc, $set: set, $push: { pinnedItems: { $each: push } } })
|
||||
.exec();
|
||||
}
|
||||
|
||||
module.exports = async function processUsers () {
|
||||
|
||||
@@ -7,7 +7,7 @@ const authorUuid = 'ed4c688c-6652-4a92-9d03-a5a79844174a'; // ... own data is do
|
||||
*/
|
||||
const connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
|
||||
|
||||
const monk = require('monk');
|
||||
const monk = require('monk'); // eslint-disable-line import/no-extraneous-dependencies
|
||||
|
||||
const dbUsers = monk(connectionString).get('users', { castIds: false });
|
||||
|
||||
@@ -45,7 +45,7 @@ function updateUsers (users) {
|
||||
if (!users || users.length === 0) {
|
||||
console.warn('All appropriate users found and modified.');
|
||||
displayData();
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
const userPromises = users.map(updateUser);
|
||||
@@ -58,7 +58,7 @@ function updateUsers (users) {
|
||||
}
|
||||
|
||||
function updateUser (user) {
|
||||
count++;
|
||||
count *= 1;
|
||||
|
||||
const isFacebook = user.auth.facebook && user.auth.facebook.id;
|
||||
const isGoogle = user.auth.google && user.auth.google.id;
|
||||
@@ -93,9 +93,10 @@ function displayData () {
|
||||
}
|
||||
|
||||
function exiting (code, msg) {
|
||||
code = code || 0; // 0 = success
|
||||
// 0 = success
|
||||
code = code || 0; // eslint-disable-line no-param-reassign
|
||||
if (code && !msg) {
|
||||
msg = 'ERROR!';
|
||||
msg = 'ERROR!'; // eslint-disable-line no-param-reassign
|
||||
}
|
||||
if (msg) {
|
||||
if (code) {
|
||||
|
||||
@@ -9,7 +9,7 @@ const progressCount = 1000;
|
||||
let count = 0;
|
||||
|
||||
async function updateUser (user) {
|
||||
count++;
|
||||
count += 1;
|
||||
|
||||
const set = {};
|
||||
let push;
|
||||
@@ -41,9 +41,9 @@ async function updateUser (user) {
|
||||
if (count % progressCount === 0) console.warn(`${count} ${user._id}`);
|
||||
|
||||
if (push) {
|
||||
return await User.update({ _id: user._id }, { $set: set, $push: push }).exec();
|
||||
return User.update({ _id: user._id }, { $set: set, $push: push }).exec();
|
||||
}
|
||||
return await User.update({ _id: user._id }, { $set: set }).exec();
|
||||
return User.update({ _id: user._id }, { $set: set }).exec();
|
||||
}
|
||||
|
||||
module.exports = async function processUsers () {
|
||||
|
||||
@@ -10,7 +10,7 @@ let authorUuid = ''; // ... own data is done
|
||||
|
||||
import uniq from 'lodash/uniq';
|
||||
|
||||
const monk = require('monk');
|
||||
const monk = require('monk'); // eslint-disable-line import/no-extraneous-dependencies
|
||||
|
||||
const testConnectionSting = ''; // FOR TEST DATABASE
|
||||
const usersTest = monk(testConnectionSting).get('users', { castIds: false });
|
||||
@@ -18,7 +18,7 @@ const groupsTest = monk(testConnectionSting).get('groups', { castIds: false });
|
||||
const challengesTest = monk(testConnectionSting).get('challenges', { castIds: false });
|
||||
const tasksTest = monk(testConnectionSting).get('tasks', { castIds: false });
|
||||
|
||||
const monk2 = require('monk');
|
||||
const monk2 = require('monk'); // eslint-disable-line import/no-extraneous-dependencies
|
||||
|
||||
const liveConnectString = ''; // FOR TEST DATABASE
|
||||
const userLive = monk2(liveConnectString).get('users', { castIds: false });
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
const { MongoClient } = require('mongodb');
|
||||
const { MongoClient } = require('mongodb'); // eslint-disable-line import/no-extraneous-dependencies
|
||||
const logger = require('./logger');
|
||||
|
||||
let dbConnection;
|
||||
@@ -16,7 +15,7 @@ function connectToDb (dbUri) {
|
||||
|
||||
logger.success(`Connected to ${dbUri}`);
|
||||
|
||||
resolve(database);
|
||||
return resolve(database);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
|
||||
const chalk = require('chalk');
|
||||
const chalk = require('chalk'); // eslint-disable-line import/no-extraneous-dependencies
|
||||
|
||||
function loggerGenerator (type, color) {
|
||||
return function logger () {
|
||||
const args = Array.from(arguments).map(arg => chalk[color](arg));
|
||||
const args = Array
|
||||
.from(arguments) // eslint-disable-line prefer-rest-params
|
||||
.map(arg => chalk[color](arg));
|
||||
console[type].apply(null, args);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
|
||||
const logger = require('./logger');
|
||||
|
||||
class Timer {
|
||||
constructor (options) {
|
||||
options = options || {};
|
||||
constructor (options = {}) {
|
||||
const warningThreshold = options.minutesWarningThreshold || 10;
|
||||
|
||||
this.count = 0;
|
||||
@@ -14,7 +12,7 @@ class Timer {
|
||||
|
||||
start () {
|
||||
this._internalTimer = setInterval(() => {
|
||||
this.count++;
|
||||
this.count *= 1;
|
||||
|
||||
const shouldWarn = this._minutesWarningThreshold < this.count;
|
||||
const logStyle = shouldWarn ? 'error' : 'warn';
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
function unique (array) {
|
||||
return Array.from(new Set(array));
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
"npm": "^6"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint --ext .js ./website/common --fix",
|
||||
"lint": "eslint --ext .js ./migrations --fix",
|
||||
"test": "npm run lint && gulp test && gulp apidoc",
|
||||
"test:build": "gulp test:prepare:build",
|
||||
"test:api-v3": "gulp test:api-v3",
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
{
|
||||
"extends": [
|
||||
"habitrpg/mocha",
|
||||
"habitrpg/esnext"
|
||||
"habitrpg/lib/mocha",
|
||||
],
|
||||
"env": {
|
||||
"node": true,
|
||||
},
|
||||
"globals": {
|
||||
"_": true,
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"env": {
|
||||
"node": true,
|
||||
"browser": true,
|
||||
},
|
||||
"extends": [
|
||||
"habitrpg/browser",
|
||||
"habitrpg/mocha",
|
||||
"habitrpg/esnext",
|
||||
],
|
||||
}
|
||||
Reference in New Issue
Block a user