aboutsummaryrefslogtreecommitdiff
path: root/anime/anime.go
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@protonmail.ch>2022-02-23 21:37:34 +0530
committerVidhu Kant Sharma <vidhukant@protonmail.ch>2022-02-23 21:37:34 +0530
commit9aeafb3e899ca96a7514d9756728afebcb907d55 (patch)
tree2054022bee2183b91d610c1149ec4722cd3aec8a /anime/anime.go
parent90a9cdb89025930fb7f455b423593a0a35799c4a (diff)
made accessing anime ranking more convinient by directly adding RankNum to the rAnime datatype
Diffstat (limited to 'anime/anime.go')
-rw-r--r--anime/anime.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/anime/anime.go b/anime/anime.go
index 9047033..292abe2 100644
--- a/anime/anime.go
+++ b/anime/anime.go
@@ -134,20 +134,20 @@ func (c Client) GetAnimeRanking(rankingType string, limit, offset int, fields []
json.Unmarshal([]byte(data), &rankingData)
// Adding all the animes in ranking list to a slice
- var animeRankingTitles []AnimeRankingTitle
- for _, element := range rankingData.Data {
- animeRankingTitles = append(
- animeRankingTitles,
- AnimeRankingTitle {
- Anime: element.Anime,
- RankNum: element.Ranking.Rank,
- },
- )
+ var animes []rAnime
+
+ for _, anime := range rankingData.Data {
+ // set RankNum for anime
+ newManga := anime.Anime
+ newManga.RankNum = anime.Ranking.Rank
+
+ // add newManga to list
+ animes = append(animes, newManga)
}
// Finally, create the AnimeRanking object
animeRanking = AnimeRanking {
- Titles: animeRankingTitles,
+ Animes: animes,
Paging: ListPaging {
NextPage: rankingData.Paging.NextPage,
PrevPage: rankingData.Paging.PrevPage,