diff --git a/internal/api/merch/repository.go b/internal/api/merch/repository.go index 4a5f3ce..fe5dd7d 100644 --- a/internal/api/merch/repository.go +++ b/internal/api/merch/repository.go @@ -339,8 +339,8 @@ func (r *Repo) getZeroPrices(userUuid string) ([]ZeroPrice, error) { WITH price_with_neighbors AS ( SELECT p.id, p.created_at, p.merch_uuid, p.price, p.origin, m.name, - LAG(price) OVER (PARTITION BY p.merch_uuid ORDER BY p.created_at, p.id) AS prev_price, - LEAD(price) OVER (PARTITION BY p.merch_uuid ORDER BY p.created_at, p.id) AS next_price + LAG(price) OVER (PARTITION BY p.merch_uuid, p.origin ORDER BY p.created_at, p.id) AS prev_price, + LEAD(price) OVER (PARTITION BY p.merch_uuid, p.origin ORDER BY p.created_at, p.id) AS next_price FROM prices AS p JOIN merch as m ON m.merch_uuid = p.merch_uuid WHERE p.deleted_at IS NULL