Fixed concurrent access
This commit is contained in:
@ -39,6 +39,9 @@ func Profile(ctx *aero.Context, viewUser *arn.User) string {
|
||||
animeList = viewUser.AnimeList()
|
||||
|
||||
// Sort by rating
|
||||
animeList.Lock()
|
||||
defer animeList.Unlock()
|
||||
|
||||
sort.Slice(animeList.Items, func(i, j int) bool {
|
||||
return animeList.Items[i].Rating.Overall > animeList.Items[j].Rating.Overall
|
||||
})
|
||||
|
@ -33,6 +33,9 @@ func GetStatsByUser(ctx *aero.Context) string {
|
||||
return ctx.Error(http.StatusInternalServerError, "Anime list not found", err)
|
||||
}
|
||||
|
||||
animeList.Lock()
|
||||
defer animeList.Unlock()
|
||||
|
||||
for _, item := range animeList.Items {
|
||||
currentWatch := item.Episodes * item.Anime().EpisodeLength
|
||||
reWatch := item.RewatchCount * item.Anime().EpisodeCount * item.Anime().EpisodeLength
|
||||
|
Reference in New Issue
Block a user