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) {
|
func BenchmarkRenderAnimeList(b *testing.B) {
|
||||||
user, _ := arn.GetUser("4J6qpK1ve")
|
user, _ := arn.GetUser("4J6qpK1ve")
|
||||||
animeList := user.AnimeList()
|
animeList := user.AnimeList()
|
||||||
|
animeList.PrefetchAnime()
|
||||||
|
|
||||||
b.ReportAllocs()
|
b.ReportAllocs()
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
|
@ -25,6 +25,7 @@ func Get(ctx *aero.Context) string {
|
|||||||
return ctx.Error(http.StatusNotFound, "Anime list not found", nil)
|
return ctx.Error(http.StatusNotFound, "Anime list not found", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
animeList.PrefetchAnime()
|
||||||
animeList.Sort()
|
animeList.Sort()
|
||||||
|
|
||||||
return ctx.HTML(components.AnimeLists(animeList.SplitByStatus(), animeList.User(), user))
|
return ctx.HTML(components.AnimeLists(animeList.SplitByStatus(), animeList.User(), user))
|
||||||
|
@ -47,27 +47,14 @@ func dashboard(ctx *aero.Context) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
animeList = animeList.WatchingAndPlanned()
|
animeList = animeList.WatchingAndPlanned()
|
||||||
|
animeList.PrefetchAnime()
|
||||||
var keys []string
|
|
||||||
|
|
||||||
for _, item := range animeList.Items {
|
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 {
|
if len(upcomingEpisodes) >= maxScheduleItems {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
futureEpisodes := anime.UpcomingEpisodes()
|
futureEpisodes := item.Anime().UpcomingEpisodes()
|
||||||
|
|
||||||
if len(futureEpisodes) == 0 {
|
if len(futureEpisodes) == 0 {
|
||||||
continue
|
continue
|
||||||
|
@ -23,6 +23,7 @@ func Get(ctx *aero.Context) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
watchingList := animeList.WatchingAndPlanned()
|
watchingList := animeList.WatchingAndPlanned()
|
||||||
|
watchingList.PrefetchAnime()
|
||||||
watchingList.Sort()
|
watchingList.Sort()
|
||||||
|
|
||||||
return utils.AllowEmbed(ctx, ctx.HTML(components.AnimeList(watchingList, animeList.User(), user)))
|
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)
|
user = utils.GetUser(ctx)
|
||||||
}, func() {
|
}, func() {
|
||||||
animeList = viewUser.AnimeList()
|
animeList = viewUser.AnimeList()
|
||||||
|
animeList.PrefetchAnime()
|
||||||
})
|
})
|
||||||
|
|
||||||
return ctx.HTML(components.Profile(viewUser, user, animeList, threads, posts, tracks))
|
return ctx.HTML(components.Profile(viewUser, user, animeList, threads, posts, tracks))
|
||||||
|
Loading…
Reference in New Issue
Block a user