From c205195a7cec2b7f7bd8122c75a6eb0ba4366d55 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Mon, 17 Jul 2017 23:49:11 +0200 Subject: [PATCH] Improved airing anime --- jobs/airing-anime/airing-anime.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/jobs/airing-anime/airing-anime.go b/jobs/airing-anime/airing-anime.go index d1dec2ee..09de8914 100644 --- a/jobs/airing-anime/airing-anime.go +++ b/jobs/airing-anime/airing-anime.go @@ -7,6 +7,8 @@ import ( "github.com/fatih/color" ) +const currentlyAiringBonus = 4.0 + func main() { color.Yellow("Caching airing anime") @@ -19,7 +21,18 @@ func main() { } sort.Slice(animeList, func(i, j int) bool { - return animeList[i].Rating.Overall > animeList[j].Rating.Overall + scoreA := animeList[i].Rating.Overall + scoreB := animeList[j].Rating.Overall + + if animeList[i].Status == "current" { + scoreA += currentlyAiringBonus + } + + if animeList[j].Status == "current" { + scoreB += currentlyAiringBonus + } + + return scoreA > scoreB }) // Convert to small anime list