We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 14f1073 commit f73a495Copy full SHA for f73a495
quiz-service/quiz-domain/src/main/kotlin/com/grepp/quizy/quiz/domain/quizread/UserSearchedQuiz.kt
@@ -215,15 +215,12 @@ data class QuizDetailOption(
215
QuizDetailOption(
216
option.optionNumber,
217
option.content,
218
- roundUp(
219
- option.selectionCount.toDouble() /
220
- total.toDouble()
221
- ),
+ calculateSelectionRatio(option.selectionCount.toDouble(), total.toDouble()),
222
imagePath = imagePath
223
)
224
225
- private fun roundUp(value: Double) =
226
- round(value * 100) / 100.0
+ private fun calculateSelectionRatio(value: Double, total: Double) =
+ if (total > 0.0) round(value / total * 100) / 100.0 else 0.0
227
}
228
229
0 commit comments