fix: for different count types
This commit is contained in:
parent
9b408e7520
commit
5218d5cd28
4 changed files with 17 additions and 4 deletions
|
@ -68,7 +68,7 @@ class AnilistQueries {
|
|||
|
||||
suspend fun getUserStatistics(id: Int, sort: String = "ID"): Query.StatisticsResponse? {
|
||||
return executeQuery<Query.StatisticsResponse>(
|
||||
"""{User(id:$id){id name statistics{anime{...UserStatistics}manga{...UserStatistics}}}}fragment UserStatistics on UserStatistics{count meanScore standardDeviation minutesWatched episodesWatched chaptersRead volumesRead formats(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds format}statuses(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds status}scores(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds score}lengths(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds length}releaseYears(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds releaseYear}startYears(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds startYear}genres(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds genre}tags(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds tag{id name}}countries(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds country}voiceActors(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds voiceActor{id name{first middle last full native alternative userPreferred}}characterIds}staff(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds staff{id name{first middle last full native alternative userPreferred}}}studios(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds studio{id name isAnimationStudio}}}""",
|
||||
"""{User(id:$id){id name mediaListOptions{scoreFormat}statistics{anime{...UserStatistics}manga{...UserStatistics}}}}fragment UserStatistics on UserStatistics{count meanScore standardDeviation minutesWatched episodesWatched chaptersRead volumesRead formats(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds format}statuses(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds status}scores(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds score}lengths(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds length}releaseYears(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds releaseYear}startYears(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds startYear}genres(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds genre}tags(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds tag{id name}}countries(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds country}voiceActors(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds voiceActor{id name{first middle last full native alternative userPreferred}}characterIds}staff(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds staff{id name{first middle last full native alternative userPreferred}}}studios(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds studio{id name isAnimationStudio}}}""",
|
||||
force = true,
|
||||
show = true
|
||||
)
|
||||
|
|
|
@ -326,6 +326,8 @@ class Query {
|
|||
val id: Int,
|
||||
@SerialName("name")
|
||||
val name: String,
|
||||
@SerialName("mediaListOptions")
|
||||
val mediaListOptions: MediaListOptions,
|
||||
@SerialName("statistics")
|
||||
val statistics: StatisticsTypes
|
||||
)
|
||||
|
|
|
@ -164,7 +164,7 @@ data class Favourites(
|
|||
@Serializable
|
||||
data class MediaListOptions(
|
||||
// The score format the user is using for media lists
|
||||
// @SerialName("scoreFormat") var scoreFormat: ScoreFormat?,
|
||||
@SerialName("scoreFormat") var scoreFormat: String?,
|
||||
|
||||
// The default order list rows should be displayed in
|
||||
@SerialName("rowOrder") var rowOrder: String?,
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue