Fix wrong MangaBaka scores for step sizes > 1 (#3740)

* Fix wrong MangaBaka scores for step sizes > 1

We're actually sending the index of the score type in the list, not
the score itself.

Overriding indexToScore solves that issue.

Also refactored the ranges to be constants for consistency.

* Changelog
This commit is contained in:
MajorTanya
2026-08-12 16:38:49 +02:00
committed by GitHub
parent 2506b04964
commit cd1f426945
2 changed files with 31 additions and 15 deletions
+1
View File
@@ -14,6 +14,7 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co
### Fixed
- Fixed app and extension update check running again on configuration change ([@AntsyLich](https://github.com/AntsyLich)) ([#3708](https://github.com/mihonapp/mihon/pull/3708))
- Fixed MangaBaka user start/finish dates drifting in negative offset timezones ([@MajorTanya](https://github.com/MajorTanya)) ([#3711](https://github.com/mihonapp/mihon/pull/3711))
- Fixed MangaBaka scores being wrong when score step size was set to > 1 ([@MajorTanya](https://github.com/MajorTanya)) ([#3740](https://github.com/mihonapp/mihon/pull/3740))
## [v0.20.4] - 2026-08-05
### Fixed
@@ -49,21 +49,12 @@ class MangaBaka(id: Long) : BaseTracker(id, "MangaBaka"), DeletableTracker {
override fun getCompletionStatus(): Long = COMPLETED
override fun getScoreList(): ImmutableList<String> {
return when (scorePreference.get()) {
// 1, 2, ..., 99, 100
STEP_1 -> IntRange(0, 100).map(Int::toString).toImmutableList()
// 5, 10, ..., 95, 100
STEP_5 -> IntRange(0, 100).step(5).map(Int::toString).toImmutableList()
// 10, 20, ..., 90, 100
STEP_10 -> IntRange(0, 100).step(10).map(Int::toString).toImmutableList()
// 20, 40, ..., 80, 100
STEP_20 -> IntRange(0, 100).step(20).map(Int::toString).toImmutableList()
// 25, 50, 75, 100
STEP_25 -> IntRange(0, 100).step(25).map(Int::toString).toImmutableList()
else -> throw Exception("Unknown score type")
}
}
override fun getScoreList(): ImmutableList<String> = getScoreRange().map(Int::toString).toImmutableList()
// score preference only dictates step size, scores are always 0-100
override fun get10PointScore(track: DomainTrack): Double = track.score / 10.0
override fun indexToScore(index: Int): Double = getScoreRange().toList()[index].toDouble()
override fun displayScore(track: DomainTrack): String = track.score.toInt().toString()
@@ -176,6 +167,15 @@ class MangaBaka(id: Long) : BaseTracker(id, "MangaBaka"), DeletableTracker {
api.deleteLibManga(track)
}
private fun getScoreRange(): IntProgression = when (scorePreference.get()) {
STEP_1 -> STEP_1_SCORES
STEP_5 -> STEP_5_SCORES
STEP_10 -> STEP_10_SCORES
STEP_20 -> STEP_20_SCORES
STEP_25 -> STEP_25_SCORES
else -> throw Exception("Unknown score type")
}
companion object {
const val READING = 1L
const val COMPLETED = 2L
@@ -191,6 +191,21 @@ class MangaBaka(id: Long) : BaseTracker(id, "MangaBaka"), DeletableTracker {
const val STEP_20 = "STEP_20"
const val STEP_25 = "STEP_25"
// 1, 2, ..., 99, 100
private val STEP_1_SCORES = IntRange(0, 100)
// 5, 10, ..., 95, 100
private val STEP_5_SCORES = IntRange(0, 100).step(5)
// 10, 20, ..., 90, 100
private val STEP_10_SCORES = IntRange(0, 100).step(10)
// 20, 40, ..., 80, 100
private val STEP_20_SCORES = IntRange(0, 100).step(20)
// 25, 50, 75, 100
private val STEP_25_SCORES = IntRange(0, 100).step(25)
private const val SEARCH_ID_PREFIX = "id:"
}
}