From b8c9f9e9eb2921159000dd1d1a364580667a9178 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Sat, 7 Jul 2018 17:12:07 +0900 Subject: [PATCH] Almost finished with old notification deletion --- .../delete-old-notifications.go | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 patches/delete-old-notifications/delete-old-notifications.go diff --git a/patches/delete-old-notifications/delete-old-notifications.go b/patches/delete-old-notifications/delete-old-notifications.go new file mode 100644 index 00000000..6c5064fc --- /dev/null +++ b/patches/delete-old-notifications/delete-old-notifications.go @@ -0,0 +1,34 @@ +package main + +import ( + "fmt" + "time" + + "github.com/animenotifier/arn" + "github.com/fatih/color" +) + +const month = 30 * 24 * time.Hour + +func main() { + color.Yellow("Deleting private user data") + + defer arn.Node.Close() + defer color.Green("Finished.") + + for user := range arn.StreamUsers() { + color.Cyan(user.Nick) + + for _, notification := range user.Notifications().Notifications() { + if time.Since(notification.CreatedTime()) < 2*month { + continue + } + + fmt.Println(notification) + // notification.Delete() + } + + // Save in DB + // user.Save() + } +}