From 367d31aadb34ba0eb36e423a9fe004a734ee0ab4 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Sun, 2 Jul 2017 15:11:42 +0200 Subject: [PATCH] Added new background jobs --- jobs/jobs.go | 3 +++ jobs/refresh-osu/refresh-osu.go | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 jobs/refresh-osu/refresh-osu.go diff --git a/jobs/jobs.go b/jobs/jobs.go index 861992dc..74e4662f 100644 --- a/jobs/jobs.go +++ b/jobs/jobs.go @@ -29,7 +29,10 @@ var jobs = map[string]time.Duration{ "airing-anime": 10 * time.Minute, "popular-anime": 20 * time.Minute, "avatars": 30 * time.Minute, + "sync-shoboi": 8 * time.Hour, + "refresh-episodes": 10 * time.Hour, "refresh-track-titles": 10 * time.Hour, + "refresh-osu": 12 * time.Hour, "sync-anime": 12 * time.Hour, "search-index": 12 * time.Hour, } diff --git a/jobs/refresh-osu/refresh-osu.go b/jobs/refresh-osu/refresh-osu.go new file mode 100644 index 00000000..e2ac7d19 --- /dev/null +++ b/jobs/refresh-osu/refresh-osu.go @@ -0,0 +1,27 @@ +package main + +import ( + "time" + + "github.com/animenotifier/arn" + "github.com/fatih/color" +) + +func main() { + color.Yellow("Refreshing osu information") + + ticker := time.NewTicker(500 * time.Millisecond) + + for user := range arn.MustStreamUsers() { + // Get osu info + if user.RefreshOsuInfo() == nil { + arn.PrettyPrint(user.Accounts.Osu) + user.Save() + } + + // Wait for rate limiter + <-ticker.C + } + + color.Green("Finished.") +}