All files / src/utils gcs.js

100% Statements 7/7
100% Branches 7/7
100% Functions 1/1
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17                29x 21x   15x 15x     1x  
/**
 * Good Character Score (GCS) computation helper.
 *
 * GCS starts at 100 and is deducted when a user receives a warning.
 * Over time, the score recovers at +2 per month from the floor value.
 */
 
function computeDisplayScore(floor, lastDeductionMs) {
  if (floor === null || floor === undefined || floor >= 100) return 100;
  if (!lastDeductionMs) return floor;
 
  const monthsSince = (Date.now() - lastDeductionMs) / (30 * 24 * 60 * 60 * 1000);
  return Math.min(100, Math.round(floor + 2 * monthsSince));
}
 
module.exports = { computeDisplayScore };