40 lines
663 B
Go
Raw Normal View History

2017-06-22 07:48:49 +00:00
package main
import (
"fmt"
"github.com/animenotifier/arn"
"github.com/fatih/color"
)
func main() {
color.Yellow("Adding empty anime lists to users who don't have one")
// Get a stream of all users
2017-06-27 12:38:36 +00:00
allUsers, err := arn.StreamUsers()
2017-06-22 07:48:49 +00:00
if err != nil {
panic(err)
}
// Iterate over the stream
for user := range allUsers {
2017-06-22 12:32:38 +00:00
exists, err := arn.DB.Exists("AnimeList", user.ID)
if err == nil && !exists {
2017-06-22 07:48:49 +00:00
fmt.Println(user.Nick)
err := arn.DB.Set("AnimeList", user.ID, &arn.AnimeList{
UserID: user.ID,
Items: make([]*arn.AnimeListItem, 0),
})
if err != nil {
color.Red(err.Error())
}
}
}
color.Green("Finished.")
}