Fixed episode deletion

This commit is contained in:
Eduard Urbach 2019-10-10 15:01:16 +09:00
parent 3a77455422
commit 5ec435cf99
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
2 changed files with 26 additions and 1 deletions

View File

@ -49,6 +49,6 @@ func (episode *Episode) Save() {
// Delete deletes the episode list from the database.
func (episode *Episode) Delete() error {
DB.Delete("Episode", episode.AnimeID)
DB.Delete("Episode", episode.ID)
return nil
}

View File

@ -0,0 +1,25 @@
package main
import (
"github.com/akyoto/color"
"github.com/animenotifier/notify.moe/arn"
)
func main() {
color.Yellow("Fixing non-existing anime relations")
defer arn.Node.Close()
count := 0
for episode := range arn.StreamEpisodes() {
anime := episode.Anime()
if anime == nil {
color.Yellow(episode.AnimeID)
episode.Delete()
count++
}
}
color.Green("Finished deleting %d episodes.", count)
}