44 lines
835 B
Go
Raw Normal View History

2018-04-22 15:43:20 +00:00
package main
import (
"strconv"
"time"
"github.com/animenotifier/arn"
"github.com/fatih/color"
)
func main() {
color.Yellow("Adding creation dates")
defer color.Green("Finished")
defer arn.Node.Close()
2018-04-23 12:12:53 +00:00
baseTime := time.Now().Add(-6 * 30 * 24 * time.Hour)
2018-04-22 15:43:20 +00:00
irregular := time.Duration(0)
for character := range arn.StreamCharacters() {
// Skip manually created characters
if character.CreatedBy != "" {
continue
}
2018-04-22 15:43:20 +00:00
malID := character.GetMapping("myanimelist/character")
if malID != "" {
malIDNumber, err := strconv.Atoi(malID)
if err != nil {
panic(err)
}
character.Created = baseTime.Add(time.Duration(malIDNumber) * time.Minute).Format(time.RFC3339)
} else {
irregular++
character.Created = baseTime.Add(-irregular * time.Minute).Format(time.RFC3339)
}
character.Save()
}
}