44 lines
847 B
Go
Raw Normal View History

2018-04-22 15:43:20 +00:00
package main
import (
"strconv"
"time"
2019-04-23 05:45:17 +00:00
"github.com/akyoto/color"
2019-06-03 09:32:43 +00:00
"github.com/animenotifier/notify.moe/arn"
2018-04-22 15:43:20 +00:00
)
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()
}
}