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:
Matteo Pagliazzi
2019-04-01 19:24:18 +02:00
committed by GitHub
parent 95e541ae75
commit 0b8ce63c76
38 changed files with 304 additions and 42 deletions

View File

@@ -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,