From 7d70f3b0b549e34b10b6a035ad0349cd39778d3c Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Wed, 25 Apr 2018 16:51:24 +0200 Subject: [PATCH] Added patch to fix user websites --- .../fix-user-websites/fix-user-websites.go | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 patches/fix-user-websites/fix-user-websites.go diff --git a/patches/fix-user-websites/fix-user-websites.go b/patches/fix-user-websites/fix-user-websites.go new file mode 100644 index 00000000..4b7ec09c --- /dev/null +++ b/patches/fix-user-websites/fix-user-websites.go @@ -0,0 +1,29 @@ +package main + +import ( + "fmt" + + "github.com/animenotifier/arn" + "github.com/animenotifier/arn/autocorrect" + "github.com/fatih/color" +) + +func main() { + color.Yellow("Updating user references") + defer arn.Node.Close() + + count := 0 + + for user := range arn.StreamUsers() { + old := user.Website + user.Website = autocorrect.Website(user.Website) + + if user.Website != old { + fmt.Println(color.YellowString(old), "->", color.YellowString(user.Website)) + count++ + user.Save() + } + } + + color.Green("%d links have been corrected.", count) +}