Skip to content

Commit

Permalink
Fix wrong types in KitsuAlgoliaSearchItem
Browse files Browse the repository at this point in the history
This API returns start and end dates as Long and the score as Double.

Kitsu's docs claim they're strings (and they are, when requesting
manga details from Kitsu directly) but the Algolia search results
return Longs and Double, respectively.
  • Loading branch information
MajorTanya committed Aug 11, 2024
1 parent f714edf commit d318dc0
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ data class KitsuAlgoliaSearchItem(
val subtype: String?,
val posterImage: KitsuSearchItemCover?,
val synopsis: String?,
val averageRating: String?,
val startDate: String?,
val endDate: String?,
val averageRating: Double?,
val startDate: Long?,
val endDate: Long?,
) {
@Suppress("MagicNumber")
fun toTrack(): TrackSearch {
Expand All @@ -44,12 +44,12 @@ data class KitsuAlgoliaSearchItem(
cover_url = posterImage?.original ?: ""
summary = synopsis ?: ""
tracking_url = KitsuApi.mangaUrl(remote_id)
score = averageRating?.toDoubleOrNull() ?: -1.0
score = averageRating ?: -1.0
publishing_status = if (endDate == null) "Publishing" else "Finished"
publishing_type = subtype ?: ""
start_date = startDate?.let {
val outputDf = SimpleDateFormat("yyyy-MM-dd", Locale.US)
outputDf.format(Date(it.toLong() * 1000))
outputDf.format(Date(it * 1000))
} ?: ""
}
}
Expand Down

0 comments on commit d318dc0

Please sign in to comment.