diff --git a/pages/genre/genre.go b/pages/genre/genre.go index e4ab127e..2c8c5b6e 100644 --- a/pages/genre/genre.go +++ b/pages/genre/genre.go @@ -84,12 +84,10 @@ func totalCompleted(user *arn.User, animes []*arn.Anime) int { completedList := user.AnimeList().FilterStatus(arn.AnimeListStatusCompleted) for _, anime := range animes { - userAnime := completedList.Find(anime.ID) - - if userAnime != nil { - count++; + if completedList.Contains(anime.ID) { + count++ } } - return count; + return count } diff --git a/pages/genre/genre.pixy b/pages/genre/genre.pixy index 2537ffa1..7045716c 100644 --- a/pages/genre/genre.pixy +++ b/pages/genre/genre.pixy @@ -1,9 +1,7 @@ component Genre(genre string, animes []*arn.Anime, user *arn.User, userScore float64, userCompleted int) h1(title=fmt.Sprint(len(animes)) + " anime")= strings.Title(genre) - if user != nil - .average-score-total-completed - p= fmt.Sprintf("Average rating: %." + strconv.Itoa(user.Settings().Format.RatingsPrecision) + "f | Total completed: %d", userScore, userCompleted) + GenreStatistics(user, userScore, userCompleted) .corner-buttons-hide-on-mobile if user != nil @@ -13,4 +11,9 @@ component Genre(genre string, animes []*arn.Anime, user *arn.User, userScore flo a.button(href="/genres", title="View genres") RawIcon("clone") - AnimeGrid(animes, user) \ No newline at end of file + AnimeGrid(animes, user) + +component GenreStatistics(user *arn.User, userScore float64, userCompleted int) + if user != nil + .average-score-total-completed + p= fmt.Sprintf("Average rating: %." + strconv.Itoa(user.Settings().Format.RatingsPrecision) + "f | Total completed: %d", userScore, userCompleted) \ No newline at end of file