From 6c560896c84a375a8567e81117b26a03d09cffde Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Thu, 8 Mar 2018 01:45:55 +0100 Subject: [PATCH] Improved performance on users page --- pages/users/users.go | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/pages/users/users.go b/pages/users/users.go index 848745c4..6f1bb7fb 100644 --- a/pages/users/users.go +++ b/pages/users/users.go @@ -15,11 +15,7 @@ func Active(ctx *aero.Context) string { return user.HasAvatar() && user.HasNick() && user.IsActive() }) - followCount := map[*arn.User]int{} - - for _, user := range users { - followCount[user] = user.FollowersCount() - } + followCount := arn.UserFollowerCountMap() sort.Slice(users, func(i, j int) bool { if users[i].HasAvatar() != users[j].HasAvatar() { @@ -30,8 +26,8 @@ func Active(ctx *aero.Context) string { return false } - followersA := followCount[users[i]] - followersB := followCount[users[j]] + followersA := followCount[users[i].ID] + followersB := followCount[users[j].ID] if followersA == followersB { return users[i].Nick < users[j].Nick @@ -49,11 +45,7 @@ func ActiveNoAvatar(ctx *aero.Context) string { return user.IsActive() && !user.HasAvatar() }) - followCount := map[*arn.User]int{} - - for _, user := range users { - followCount[user] = user.FollowersCount() - } + followCount := arn.UserFollowerCountMap() sort.Slice(users, func(i, j int) bool { if users[i].HasAvatar() != users[j].HasAvatar() {