Skip to content

Commit

Permalink
Cyberleague: [premieroctet#159] Adapt computeBellwetherStatistics to …
Browse files Browse the repository at this point in the history
…fields that need to be between 0 and 5
  • Loading branch information
Bastien-Wappizy committed Oct 15, 2024
1 parent 39f4485 commit 84da11f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion backend/web/server/plugins/cyberleague/statistic.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const lodash = require('lodash')
const Company = require("../../models/Company")
const Score = require("../../models/Score")
const User = require("../../models/User")
const { STAT_MIN_SCORES, ANSWER_NO, ANSWER_YES, BENCHMARK_FIELDS_10 } = require("./consts")
const { STAT_MIN_SCORES, ANSWER_NO, ANSWER_YES, BENCHMARK_FIELDS_10, BENCHMARK_FIELDS_5 } = require("./consts")


const regexTest = (field, text) => {
Expand Down Expand Up @@ -155,6 +155,8 @@ const computeBellwetherStatistics = async (filters) => {
//Adapt value of field that need to be in [0,10]
if (lodash.includes(BENCHMARK_FIELDS_10, field)) {
res[field] = Math.round(bellwetherData[field].value / bellwetherData[field].count * 10)
} else if (lodash.includes(BENCHMARK_FIELDS_5, field)) {
res[field] = Math.round(bellwetherData[field].value / bellwetherData[field].count * 5)
} else {
res[field] = Math.round(bellwetherData[field].value / bellwetherData[field].count * 100) /100
}
Expand Down

0 comments on commit 84da11f

Please sign in to comment.