mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 21:27:23 +01:00
WIP: Improve User model performances (#10832)
* wip: define items as mixed objects * add default owned gear * mark modified * more mark modified * more mark modified * more mark modified * more mark modified * fix common tests * fix common tests * update mongoose * add itemsUtils * use new util function in hall controller * add tests for items utils * update website/server to mark all items as modified * start updating common code * update login incentives * update unlock * remove changes to package-lock.json * remove changes to package.json
This commit is contained in:
@@ -75,6 +75,7 @@ module.exports = function unlock (user, req = {}, analytics) {
|
||||
setWith(user, pathPart, true, Object);
|
||||
let itemName = pathPart.split('.').pop();
|
||||
removeItemByPath(user, `gear.flat.${itemName}`);
|
||||
if (user.markModified && path.indexOf('gear.owned') !== -1) user.markModified('items.gear.owned');
|
||||
}
|
||||
|
||||
// Using Object so path[1] won't create an array but an object {path: {1: value}}
|
||||
@@ -96,6 +97,7 @@ module.exports = function unlock (user, req = {}, analytics) {
|
||||
if (path.indexOf('gear.') !== -1) {
|
||||
// Using Object so path[1] won't create an array but an object {path: {1: value}}
|
||||
setWith(user, path, true, Object);
|
||||
if (user.markModified && path.indexOf('gear.owned') !== -1) user.markModified('items.gear.owned');
|
||||
}
|
||||
// Using Object so path[1] won't create an array but an object {path: {1: value}}
|
||||
setWith(user, `purchased.${path}`, true, Object);
|
||||
|
||||
Reference in New Issue
Block a user