zero price query fix
All checks were successful
/ Make image (push) Successful in 58s

This commit is contained in:
nquidox 2026-04-01 22:08:14 +03:00
parent 30b336b4cf
commit fcf74df6a1

View file

@ -127,14 +127,14 @@ func (r *repo) getZeroPrices(ctx context.Context, userId int64) ([]ZeroPrice, er
q := `
WITH price_with_neighbors AS (
SELECT
p.id, p.created_at, p.merch_id, p.price, p.origin_id, m.name,
p.id, p.created_at, p.merch_id, p.price, p.origin_id, m.name, m.merch_uuid,
LAG(price) OVER (PARTITION BY p.merch_id, p.origin_id ORDER BY p.created_at, p.id) AS prev_price,
LEAD(price) OVER (PARTITION BY p.merch_id, p.origin_id ORDER BY p.created_at, p.id) AS next_price
FROM merch_prices AS p
JOIN merch as m ON m.id = p.merch_id
WHERE p.deleted_at IS NULL
AND m.deleted_at IS NULL
AND m.user_id = 3)
AND m.user_id = $1)
SELECT
pwn.id, pwn.created_at, pwn.merch_uuid, pwn.name, mo.name