From b222d5fbc8f63b006338b2a751c531b9b0909ebd Mon Sep 17 00:00:00 2001 From: vikingowl Date: Sat, 18 Apr 2026 08:08:27 +0200 Subject: [PATCH] fix(discovery): use interval multiplication for forward-window query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pgx cannot implicitly encode int arg into text for the `$1 || ' month'` concatenation pattern (error: "unable to encode 12 into text format for text (OID 25): cannot find encode plan"). Multiplication with a known interval works directly with the int parameter and is semantically equivalent. Discovered during the T19 smoke test — the tick endpoint returned 500 on every call before this fix. --- backend/internal/domain/discovery/repository.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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`