Skip to content

Commit

Permalink
Cyberleague: [premieroctet#159] fix score populate in statistic.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Bastien-Wappizy committed Oct 16, 2024
1 parent cdb718d commit fe73483
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions backend/web/server/plugins/cyberleague/statistic.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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 = [
Expand Down

0 comments on commit fe73483

Please sign in to comment.