fix: for different count types

This commit is contained in:
rebelonion 2024-03-05 00:00:10 -06:00
parent 9b408e7520
commit 5218d5cd28
4 changed files with 17 additions and 4 deletions

View file

@ -225,9 +225,9 @@ class StatsFragment :
val chartPackets = mutableListOf<ChartPacket>()
stats.forEach { stat ->
val names: List<Int> = if (anime) {
stat?.statistics?.anime?.scores?.map { it.score } ?: emptyList()
stat?.statistics?.anime?.scores?.map { convertScore(it.score, stat.mediaListOptions.scoreFormat) } ?: emptyList()
} else {
stat?.statistics?.manga?.scores?.map { it.score } ?: emptyList()
stat?.statistics?.manga?.scores?.map { convertScore(it.score, stat.mediaListOptions.scoreFormat) } ?: emptyList()
}
val values: List<Number> = if (anime) {
when (statType) {
@ -704,6 +704,17 @@ class StatsFragment :
}
}
private fun convertScore(score: Int, type: String?): Int {
return when (type) {
"POINT_100" -> score
"POINT_10_DECIMAL" -> score
"POINT_10" -> score * 10
"POINT_5" -> score * 20
"POINT_3" -> score * 33
else -> score
}
}
companion object {
fun newInstance(user: Query.UserProfile): StatsFragment {
val args = Bundle().apply {