From 4748c72eb6f20207d2c596b070d3e7da06ff9ee1 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Thu, 10 Oct 2019 14:47:22 +0900 Subject: [PATCH] Fix non-existing anime relations --- .../fix-nil-relations/fix-nil-relations.go | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 patches/fix-nil-relations/fix-nil-relations.go diff --git a/patches/fix-nil-relations/fix-nil-relations.go b/patches/fix-nil-relations/fix-nil-relations.go new file mode 100644 index 00000000..1d7532b2 --- /dev/null +++ b/patches/fix-nil-relations/fix-nil-relations.go @@ -0,0 +1,24 @@ +package main + +import ( + "github.com/akyoto/color" + "github.com/animenotifier/notify.moe/arn" +) + +func main() { + color.Yellow("Fixing non-existing anime relations") + defer color.Green("Finished.") + defer arn.Node.Close() + + for anime := range arn.StreamAnime() { + relations := anime.Relations() + + if relations == nil { + relations = &arn.AnimeRelations{ + AnimeID: anime.ID, + } + + relations.Save() + } + } +}