Members: user .lean() to improve performances (#10399)

* perf(members): use lean where possible

* fix unit tests

* fix unit tests and update calls to old function

* simplify code and add tests
This commit is contained in:
Matteo Pagliazzi
2018-05-28 13:38:59 +02:00
committed by GitHub
parent ac90a40be5
commit bf424573a4
8 changed files with 101 additions and 39 deletions

View File

@@ -7,6 +7,9 @@ import {
questActivityWebhook,
userActivityWebhook,
} from '../../../../../website/server/libs/webhook';
import {
model as User,
} from '../../../../../website/server/models/user';
import {
generateUser,
} from '../../../../helpers/api-unit.helper.js';
@@ -306,17 +309,6 @@ describe('webhooks', () => {
return this;
},
},
addComputedStatsToJSONObj () {
let mockStats = Object.assign({
maxHealth: 50,
maxMP: 103,
toNextLevel: 40,
}, this.stats);
delete mockStats.toJSON;
return mockStats;
},
},
task: {
text: 'text',
@@ -324,6 +316,15 @@ describe('webhooks', () => {
direction: 'up',
delta: 176,
};
let mockStats = Object.assign({
maxHealth: 50,
maxMP: 103,
toNextLevel: 40,
}, data.user.stats);
delete mockStats.toJSON;
sandbox.stub(User, 'addComputedStatsToJSONObj').returns(mockStats);
});
it('sends task and stats data', () => {