Skip to content

Commit f73a495

Browse files
committed
hotfix : fix quiz selection ratio calculation
1 parent 14f1073 commit f73a495

File tree

1 file changed

+3
-6
lines changed
  • quiz-service/quiz-domain/src/main/kotlin/com/grepp/quizy/quiz/domain/quizread

1 file changed

+3
-6
lines changed

quiz-service/quiz-domain/src/main/kotlin/com/grepp/quizy/quiz/domain/quizread/UserSearchedQuiz.kt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,15 +215,12 @@ data class QuizDetailOption(
215215
QuizDetailOption(
216216
option.optionNumber,
217217
option.content,
218-
roundUp(
219-
option.selectionCount.toDouble() /
220-
total.toDouble()
221-
),
218+
calculateSelectionRatio(option.selectionCount.toDouble(), total.toDouble()),
222219
imagePath = imagePath
223220
)
224221

225-
private fun roundUp(value: Double) =
226-
round(value * 100) / 100.0
222+
private fun calculateSelectionRatio(value: Double, total: Double) =
223+
if (total > 0.0) round(value / total * 100) / 100.0 else 0.0
227224
}
228225
}
229226

0 commit comments

Comments
 (0)