From fe734831f7bbb6ecc633827dcd1a82663bcfa2cf Mon Sep 17 00:00:00 2001 From: Bastien Seree Date: Wed, 16 Oct 2024 10:50:29 +0200 Subject: [PATCH] Cyberleague: [#159] fix score populate in statistic.js --- backend/web/server/plugins/cyberleague/statistic.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/backend/web/server/plugins/cyberleague/statistic.js b/backend/web/server/plugins/cyberleague/statistic.js index 4bba8df81..bfd9eaa42 100644 --- a/backend/web/server/plugins/cyberleague/statistic.js +++ b/backend/web/server/plugins/cyberleague/statistic.js @@ -3,7 +3,7 @@ const Company = require("../../models/Company") const Score = require("../../models/Score") const User = require("../../models/User") const Statistic = require("../../models/Statistic") -const { STAT_MIN_SCORES, ANSWER_NO, ANSWER_YES, BENCHMARK_FIELDS_10, BENCHMARK_FIELDS_5, ENOUGH_SCORES_NO, ENOUGH_SCORES_YES } = require("./consts") +const { STAT_MIN_SCORES, ANSWER_NO, ANSWER_YES, BENCHMARK_FIELDS_10, BENCHMARK_FIELDS_5, ENOUGH_SCORES_NO, ENOUGH_SCORES_YES, COMPLETED_YES } = require("./consts") const regexTest = (field, text) => { @@ -67,13 +67,14 @@ const computeBellwetherStatistics = async (filters) => { const users = await User.find({company: {$in: companies.map((c) => {return c._id})}}) - scores = await Score.find({creator: {$in: users.map((u) => {return u._id})}}).populate([ - {path: 'answers', populate: {path:'answer'}}, - {path: 'answers', populate: {path: 'question', $match: {is_bellwether: true}, populate: {path: 'text'}}} + scores = await Score.find({creator: {$in: users.map((u) => {return u._id})}, completed: COMPLETED_YES}).populate([ + {path: 'answers', populate: {path: 'question', $match: {is_bellwether: true}}} ]) } else { - scores = await Score.find() + scores = await Score.find({completed: COMPLETED_YES}).populate([ + {path: 'answers', populate: {path: 'question', $match: {is_bellwether: true}}} + ]) } const fields = [