Browse Source

fix: issue with the biggest group calculus

I've known about this one for almost a year.
Feels good to finally get around to it.
mj-v1.14.3
domi41 1 year ago
parent
commit
f70b353236
  1. 11
      models/poll_tally.go

11
models/poll_tally.go

@ -96,19 +96,24 @@ func (pct *PollCandidateTally) GetBiggestGroup(aroundGrade uint8) (groupSize int
for k, _ := range pct.Poll.GetGradationList() {
grade := uint8(k)
//for _, grade := range pct.Poll.GetGrades() {
gradeAmount := int(pct.Grades[grade].Amount)
if 0 == gradeAmount {
continue
}
if grade < aroundGrade {
belowGroupSize += int(pct.Grades[grade].Amount)
belowGroupSize += gradeAmount
belowGroupGrade = grade
}
if grade > aroundGrade {
aboveGroupSize += int(pct.Grades[grade].Amount)
aboveGroupSize += gradeAmount
if 0 == aboveGroupGrade {
aboveGroupGrade = grade
}
}
}
// /!. Assumption of LOW median with `>` /!.
if aboveGroupSize > belowGroupSize {
return aboveGroupSize, aboveGroupSign, aboveGroupGrade
}

Loading…
Cancel
Save