From 94d8104925ce78b87a8b01a94c04213c8694819e Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Fri, 9 Nov 2018 03:41:54 +0900 Subject: [PATCH] Improved user references reset patch --- pages/anime/anime.go | 2 +- pages/profile/followers.go | 2 +- patches/user-references/user-references.go | 13 ++++++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/pages/anime/anime.go b/pages/anime/anime.go index 4f05d0ec..7ddc43e4 100644 --- a/pages/anime/anime.go +++ b/pages/anime/anime.go @@ -51,7 +51,7 @@ func Get(ctx *aero.Context) string { } } - arn.SortUsersLastSeen(friends) + arn.SortUsersLastSeenFirst(friends) } // Sort relations by start date diff --git a/pages/profile/followers.go b/pages/profile/followers.go index 3155df4e..b454389b 100644 --- a/pages/profile/followers.go +++ b/pages/profile/followers.go @@ -19,7 +19,7 @@ func GetFollowers(ctx *aero.Context) string { } followers := viewUser.Followers() - arn.SortUsersLastSeen(followers) + arn.SortUsersLastSeenFirst(followers) return ctx.HTML(components.ProfileFollowers(followers, viewUser, utils.GetUser(ctx), ctx.URI())) diff --git a/patches/user-references/user-references.go b/patches/user-references/user-references.go index f5aab5f7..1dc739fa 100644 --- a/patches/user-references/user-references.go +++ b/patches/user-references/user-references.go @@ -17,7 +17,16 @@ func main() { // Iterate over the stream count := 0 - for user := range arn.StreamUsers() { + users, err := arn.AllUsers() + arn.PanicOnError(err) + + // Make the most recently seen users overwrite the references of older accounts. + // Some people accidentally created 2 accounts and in case of overlaps we want + // to keep the references for the account that is more likely used. + arn.SortUsersLastSeenLast(users) + + // Write new references + for _, user := range users { count++ println(count, user.Nick) @@ -34,6 +43,8 @@ func main() { if user.Accounts.Facebook.ID != "" { user.ConnectFacebook(user.Accounts.Facebook.ID) } + + user.Save() } color.Green("Finished.")