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

@@ -8,6 +8,9 @@ import {
basicFields as basicGroupFields,
model as Group,
} from '../../models/group';
import {
model as User,
} from '../../models/user';
import * as Tasks from '../../models/task';
import _ from 'lodash';
import * as passwordUtils from '../../libs/password';
@@ -90,7 +93,7 @@ api.getUser = {
let {daysMissed} = user.daysUserHasMissed(new Date(), req);
userToJSON.needsCron = false;
if (daysMissed > 0) userToJSON.needsCron = true;
user.addComputedStatsToJSONObj(userToJSON.stats);
User.addComputedStatsToJSONObj(userToJSON.stats, userToJSON);
}
return res.respond(200, userToJSON);