diff options
Diffstat (limited to 'internal/cli')
-rw-r--r-- | internal/cli/refresh_feeds.go | 10 | ||||
-rw-r--r-- | internal/cli/scheduler.go | 13 |
2 files changed, 19 insertions, 4 deletions
diff --git a/internal/cli/refresh_feeds.go b/internal/cli/refresh_feeds.go index 3af4ecdb..e10600f3 100644 --- a/internal/cli/refresh_feeds.go +++ b/internal/cli/refresh_feeds.go @@ -18,7 +18,15 @@ func refreshFeeds(store *storage.Storage) { var wg sync.WaitGroup startTime := time.Now() - jobs, err := store.NewBatch(config.Opts.BatchSize()) + + // Generate a batch of feeds for any user that has feeds to refresh. + batchBuilder := store.NewBatchBuilder() + batchBuilder.WithBatchSize(config.Opts.BatchSize()) + batchBuilder.WithErrorLimit(config.Opts.PollingParsingErrorLimit()) + batchBuilder.WithoutDisabledFeeds() + batchBuilder.WithNextCheckExpired() + + jobs, err := batchBuilder.FetchJobs() if err != nil { slog.Error("Unable to fetch jobs from database", slog.Any("error", err)) return diff --git a/internal/cli/scheduler.go b/internal/cli/scheduler.go index 6bde37c0..9f69d7ea 100644 --- a/internal/cli/scheduler.go +++ b/internal/cli/scheduler.go @@ -20,6 +20,7 @@ func runScheduler(store *storage.Storage, pool *worker.Pool) { pool, config.Opts.PollingFrequency(), config.Opts.BatchSize(), + config.Opts.PollingParsingErrorLimit(), ) go cleanupScheduler( @@ -28,10 +29,16 @@ func runScheduler(store *storage.Storage, pool *worker.Pool) { ) } -func feedScheduler(store *storage.Storage, pool *worker.Pool, frequency, batchSize int) { +func feedScheduler(store *storage.Storage, pool *worker.Pool, frequency, batchSize, errorLimit int) { for range time.Tick(time.Duration(frequency) * time.Minute) { - jobs, err := store.NewBatch(batchSize) - if err != nil { + // Generate a batch of feeds for any user that has feeds to refresh. + batchBuilder := store.NewBatchBuilder() + batchBuilder.WithBatchSize(batchSize) + batchBuilder.WithErrorLimit(errorLimit) + batchBuilder.WithoutDisabledFeeds() + batchBuilder.WithNextCheckExpired() + + if jobs, err := batchBuilder.FetchJobs(); err != nil { slog.Error("Unable to fetch jobs from database", slog.Any("error", err)) } else { slog.Info("Created a batch of feeds", |