mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +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,8 @@ module.exports = function updateStats (user, stats, req = {}, analytics) {
|
||||
} else {
|
||||
user.items.eggs.Wolf = 1;
|
||||
}
|
||||
|
||||
if (user.markModified) user.markModified('items.eggs');
|
||||
}
|
||||
each({
|
||||
vice1: 30,
|
||||
@@ -84,10 +86,12 @@ module.exports = function updateStats (user, stats, req = {}, analytics) {
|
||||
}, (lvl, k) => {
|
||||
if (user.stats.lvl >= lvl && !user.flags.levelDrops[k]) {
|
||||
user.flags.levelDrops[k] = true;
|
||||
if (!user.items.quests[k])
|
||||
user.items.quests[k] = 0;
|
||||
user.items.quests[k]++;
|
||||
if (user.markModified) user.markModified('flags.levelDrops');
|
||||
|
||||
if (!user.items.quests[k]) user.items.quests[k] = 0;
|
||||
user.items.quests[k]++;
|
||||
if (user.markModified) user.markModified('items.quests');
|
||||
|
||||
if (analytics) {
|
||||
analytics.track('acquire item', {
|
||||
uuid: user._id,
|
||||
|
||||
Reference in New Issue
Block a user