1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-11 17:51:01 +00:00

fix(storage): revert DISTINCT in FetchJobs query

This commit is contained in:
Frédéric Guillot 2025-08-08 16:53:52 -07:00
parent 598d4d4f51
commit e0ca92fca4

View file

@ -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. // 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. // 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) { 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 { if len(b.conditions) > 0 {
query += " WHERE " + strings.Join(b.conditions, " AND ") 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 { if b.batchSize > 0 {
query += fmt.Sprintf(" LIMIT %d", b.batchSize) query += fmt.Sprintf(" LIMIT %d", b.batchSize)