diff --git a/backend/internal/domain/discovery/repository.go b/backend/internal/domain/discovery/repository.go index bad1ee7..4425ab9 100644 --- a/backend/internal/domain/discovery/repository.go +++ b/backend/internal/domain/discovery/repository.go @@ -47,7 +47,7 @@ func (r *pgRepository) PickStaleBuckets(ctx context.Context, forwardMonths, limi SELECT id, land, region, year_month, last_queried_at, coalesce(last_error, ''), created_at FROM discovery_buckets WHERE year_month >= to_char(date_trunc('month', now()), 'YYYY-MM') - AND year_month <= to_char(date_trunc('month', now()) + ($1 || ' month')::interval, 'YYYY-MM') + AND year_month <= to_char(date_trunc('month', now()) + ($1 * interval '1 month'), 'YYYY-MM') AND (last_queried_at IS NULL OR last_queried_at < now() - interval '7 days') ORDER BY last_queried_at NULLS FIRST, year_month LIMIT $2`