mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 06:07:21 +01:00
Upgrade tests tools and lint migrations and scripts (part 2) (#9998)
* upgrade gulp-babel * upgrade babel-eslint * upgrade eslint-friendly-formatter * start upgrading chai * start to upgrade eslint * restore skipped tests * start to upgrqde monk * fix linting and remove unused file * fix mocha notifications, and common tests * fix unit tests * start to fix initrgration tests * more integration tests fixes * upgrade monk to latest version * lint /scripts * migrations: start moving to /archive unused migrations and run eslint with --fix * lint migrations * fix more integration tests * fix test
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
/*
|
||||
const migrationName = 'AchievementRestore';
|
||||
const authorName = 'TheHollidayInn'; // in case script author needs to know when their ...
|
||||
const authorUuid = ''; //... own data is done
|
||||
const authorUuid = ''; // ... own data is done
|
||||
*/
|
||||
|
||||
/*
|
||||
* This migraition will copy user data from prod to test
|
||||
*/
|
||||
import Bluebird from 'bluebird';
|
||||
|
||||
const monk = require('monk');
|
||||
const connectionString = 'mongodb://localhost/new-habit';
|
||||
const Users = monk(connectionString).get('users', { castIds: false });
|
||||
|
||||
const monkOld = require('monk');
|
||||
const oldConnectionSting = 'mongodb://localhost/old-habit';
|
||||
const UsersOld = monk(oldConnectionSting).get('users', { castIds: false });
|
||||
|
||||
@@ -52,21 +52,19 @@ function getAchievementUpdate (newUser, oldUser) {
|
||||
achievementsUpdate.rebirthLevel = oldAchievements.rebirthLevel;
|
||||
}
|
||||
|
||||
//All others
|
||||
// All others
|
||||
const indexsToIgnore = ['ultimateGearSets', 'challenges', 'quests', 'rebirthLevel'];
|
||||
for (let index in oldAchievements) {
|
||||
if (indexsToIgnore.indexOf(index) !== -1) continue;
|
||||
if (indexsToIgnore.indexOf(index) !== -1) continue; // eslint-disable-line no-continue
|
||||
|
||||
if (!achievementsUpdate[index]) {
|
||||
achievementsUpdate[index] = oldAchievements[index];
|
||||
continue;
|
||||
continue; // eslint-disable-line no-continue
|
||||
}
|
||||
|
||||
if (Number.isInteger(oldAchievements[index])) {
|
||||
achievementsUpdate[index] += oldAchievements[index];
|
||||
} else {
|
||||
if (oldAchievements[index] === true) achievementsUpdate[index] = true;
|
||||
}
|
||||
} else if (oldAchievements[index] === true) achievementsUpdate[index] = true;
|
||||
}
|
||||
|
||||
return achievementsUpdate;
|
||||
@@ -77,6 +75,7 @@ module.exports = async function achievementRestore () {
|
||||
];
|
||||
|
||||
for (let index in userIds) {
|
||||
/* eslint-disable no-await-in-loop */
|
||||
const userId = userIds[index];
|
||||
const oldUser = await UsersOld.findOne({_id: userId}, 'achievements');
|
||||
const newUser = await Users.findOne({_id: userId}, 'achievements');
|
||||
@@ -85,9 +84,10 @@ module.exports = async function achievementRestore () {
|
||||
{_id: userId},
|
||||
{
|
||||
$set: {
|
||||
'achievements': achievementUpdate,
|
||||
achievements: achievementUpdate,
|
||||
},
|
||||
});
|
||||
console.log(`Updated ${userId}`);
|
||||
/* eslint-enable no-await-in-loop */
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user