From e0ca92fca47d1ba4477ca12c3df18ac57b7210c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Fri, 8 Aug 2025 16:53:52 -0700 Subject: [PATCH] fix(storage): revert `DISTINCT` in `FetchJobs` query --- internal/storage/batch.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/internal/storage/batch.go b/internal/storage/batch.go index 2a720cb7..a7939ee1 100644 --- a/internal/storage/batch.go +++ b/internal/storage/batch.go @@ -70,16 +70,15 @@ func (b *BatchBuilder) WithLimitPerHost(limit int) *BatchBuilder { } // FetchJobs retrieves a batch of jobs based on the conditions set in the builder. -// It ensures that each job is unique by feed URL to avoid making too many concurrent requests to the same website. // When limitPerHost is set, it limits the number of jobs per feed hostname to prevent overwhelming a single host. func (b *BatchBuilder) FetchJobs() (model.JobList, error) { - query := `SELECT DISTINCT ON (feed_url) id, user_id, feed_url FROM feeds` + query := `SELECT id, user_id, feed_url FROM feeds` if len(b.conditions) > 0 { query += " WHERE " + strings.Join(b.conditions, " AND ") } - query += " ORDER BY feed_url, next_check_at ASC" + query += " ORDER BY next_check_at ASC" if b.batchSize > 0 { query += fmt.Sprintf(" LIMIT %d", b.batchSize)