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 10
  • Loading branch information
Bastien-Wappizy committed Oct 15, 2024
1 parent 9fcce2d commit 539cceb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions 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 } = require("./consts")
const { STAT_MIN_SCORES, ANSWER_NO, ANSWER_YES, BENCHMARK_FIELDS_10 } = require("./consts")


const regexTest = (field, text) => {
Expand Down Expand Up @@ -152,7 +152,12 @@ const computeBellwetherStatistics = async (filters) => {

//Compute ratios for bellwether / benchmark
fields.forEach((field) => {
res[field] = Math.round(bellwetherData[field].value / bellwetherData[field].count * 100) /100
//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 {
res[field] = Math.round(bellwetherData[field].value / bellwetherData[field].count * 100) /100
}
})

return res
Expand Down

0 comments on commit 539cceb

Please sign in to comment.