Added a patch to fix broken relations
This commit is contained in:
parent
6cd8f725ae
commit
516b4a1966
35
patches/fix-broken-relations/fix-broken-relations.go
Normal file
35
patches/fix-broken-relations/fix-broken-relations.go
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/animenotifier/arn"
|
||||||
|
"github.com/fatih/color"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
color.Yellow("Fixing broken anime relations")
|
||||||
|
|
||||||
|
defer arn.Node.Close()
|
||||||
|
|
||||||
|
count := 0
|
||||||
|
|
||||||
|
for relations := range arn.StreamAnimeRelations() {
|
||||||
|
brokenIDs := []string{}
|
||||||
|
|
||||||
|
for _, item := range relations.Items {
|
||||||
|
_, err := arn.GetAnime(item.AnimeID)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
brokenIDs = append(brokenIDs, item.AnimeID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, brokenID := range brokenIDs {
|
||||||
|
relations.Remove(brokenID)
|
||||||
|
count++
|
||||||
|
}
|
||||||
|
|
||||||
|
relations.Save()
|
||||||
|
}
|
||||||
|
|
||||||
|
color.Green("Finished removing %d broken relations.", count)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user