Explicit PrefetchAnime call
This commit is contained in:
parent
9d28c652c0
commit
a94b69d671
@ -29,6 +29,7 @@ func BenchmarkRenderThread(b *testing.B) {
|
||||
func BenchmarkRenderAnimeList(b *testing.B) {
|
||||
user, _ := arn.GetUser("4J6qpK1ve")
|
||||
animeList := user.AnimeList()
|
||||
animeList.PrefetchAnime()
|
||||
|
||||
b.ReportAllocs()
|
||||
b.ResetTimer()
|
||||
|
@ -25,6 +25,7 @@ func Get(ctx *aero.Context) string {
|
||||
return ctx.Error(http.StatusNotFound, "Anime list not found", nil)
|
||||
}
|
||||
|
||||
animeList.PrefetchAnime()
|
||||
animeList.Sort()
|
||||
|
||||
return ctx.HTML(components.AnimeLists(animeList.SplitByStatus(), animeList.User(), user))
|
||||
|
@ -47,27 +47,14 @@ func dashboard(ctx *aero.Context) string {
|
||||
}
|
||||
|
||||
animeList = animeList.WatchingAndPlanned()
|
||||
|
||||
var keys []string
|
||||
animeList.PrefetchAnime()
|
||||
|
||||
for _, item := range animeList.Items {
|
||||
keys = append(keys, item.AnimeID)
|
||||
}
|
||||
|
||||
objects, getErr := arn.DB.GetMany("Anime", keys)
|
||||
|
||||
if getErr != nil {
|
||||
return
|
||||
}
|
||||
|
||||
allAnimeInList := objects.([]*arn.Anime)
|
||||
|
||||
for _, anime := range allAnimeInList {
|
||||
if len(upcomingEpisodes) >= maxScheduleItems {
|
||||
break
|
||||
}
|
||||
|
||||
futureEpisodes := anime.UpcomingEpisodes()
|
||||
futureEpisodes := item.Anime().UpcomingEpisodes()
|
||||
|
||||
if len(futureEpisodes) == 0 {
|
||||
continue
|
||||
|
@ -23,6 +23,7 @@ func Get(ctx *aero.Context) string {
|
||||
}
|
||||
|
||||
watchingList := animeList.WatchingAndPlanned()
|
||||
watchingList.PrefetchAnime()
|
||||
watchingList.Sort()
|
||||
|
||||
return utils.AllowEmbed(ctx, ctx.HTML(components.AnimeList(watchingList, animeList.User(), user)))
|
||||
|
@ -35,6 +35,7 @@ func Profile(ctx *aero.Context, viewUser *arn.User) string {
|
||||
user = utils.GetUser(ctx)
|
||||
}, func() {
|
||||
animeList = viewUser.AnimeList()
|
||||
animeList.PrefetchAnime()
|
||||
})
|
||||
|
||||
return ctx.HTML(components.Profile(viewUser, user, animeList, threads, posts, tracks))
|
||||
|
Loading…
Reference in New Issue
Block a user