36 lines
596 B
Go
Raw Normal View History

2018-03-26 20:24:42 +00:00
package main
import (
2019-04-23 05:45:17 +00:00
"github.com/akyoto/color"
2019-04-23 05:52:55 +00:00
"github.com/animenotifier/arn"
2018-03-26 20:24:42 +00:00
)
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)
}