aboutsummaryrefslogtreecommitdiffstats
path: root/walrss/internal/rss/watcher.go
diff options
context:
space:
mode:
Diffstat (limited to 'walrss/internal/rss/watcher.go')
-rw-r--r--walrss/internal/rss/watcher.go15
1 files changed, 9 insertions, 6 deletions
diff --git a/walrss/internal/rss/watcher.go b/walrss/internal/rss/watcher.go
index e7036c1..5a000cb 100644
--- a/walrss/internal/rss/watcher.go
+++ b/walrss/internal/rss/watcher.go
@@ -12,15 +12,18 @@ func StartWatcher(st *state.State) {
currentTime := time.Now().UTC()
time.Sleep(time.Minute * time.Duration(60-currentTime.Minute()))
- if err := ProcessFeeds(st, db.SendDayFromWeekday(currentTime.Weekday()), currentTime.Hour()+1); err != nil {
- log.Error().Err(err).Str("location", "feed watcher").Send()
- }
+ runFeedProcessor(st, currentTime)
ticker := time.NewTicker(time.Hour)
for currentTime := range ticker.C {
- if err := ProcessFeeds(st, db.SendDayFromWeekday(currentTime.Weekday()), currentTime.Hour()); err != nil {
- log.Error().Err(err).Str("location", "feed watcher").Send()
- }
+ runFeedProcessor(st, currentTime)
}
}()
}
+
+func runFeedProcessor(st *state.State, currentTime time.Time) {
+ log.Info().Str("location", "feed watcher").Msg("running hourly job")
+ if err := ProcessFeeds(st, db.SendDayFromWeekday(currentTime.Weekday()), currentTime.Hour()+1); err != nil {
+ log.Error().Err(err).Str("location", "feed watcher").Send()
+ }
+}