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

@@ -2,6 +2,9 @@ import got from 'got';
import { isURL } from 'validator';
import logger from './logger';
import nconf from 'nconf';
import {
model as User,
} from '../models/user';
const IS_PRODUCTION = nconf.get('IS_PROD');
@@ -72,7 +75,7 @@ export let taskScoredWebhook = new WebhookSender({
transformData (data) {
let { user, task, direction, delta } = data;
let extendedStats = user.addComputedStatsToJSONObj(user.stats.toJSON());
let extendedStats = User.addComputedStatsToJSONObj(user.stats.toJSON(), user);
let userData = {
// _id: user._id, added automatically when the webhook is sent