40 lines
680 B
Go
Raw Normal View History

2017-07-21 08:10:48 +00:00
package main
import (
"fmt"
"github.com/animenotifier/arn"
"github.com/fatih/color"
)
func main() {
color.Yellow("Adding user follows to users who don't have one")
// Get a stream of all users
allUsers, err := arn.StreamUsers()
2017-10-04 06:12:12 +00:00
arn.PanicOnError(err)
2017-07-21 08:10:48 +00:00
// Iterate over the stream
for user := range allUsers {
2017-10-04 06:12:12 +00:00
exists, err := arn.DB.Exists("UserFollows", user.ID)
2017-07-21 08:10:48 +00:00
2017-10-04 06:12:12 +00:00
if err != nil || exists {
continue
}
2017-07-21 08:10:48 +00:00
fmt.Println(user.Nick)
follows := &arn.UserFollows{}
follows.UserID = user.ID
follows.Items = user.Following
err = arn.DB.Set("UserFollows", follows.UserID, follows)
if err != nil {
color.Red(err.Error())
}
}
color.Green("Finished.")
}