Skip to content

Commit

Permalink
fix(sql): ordering where sorted_limited is used
Browse files Browse the repository at this point in the history
  • Loading branch information
1000101 committed Feb 29, 2024
1 parent 0cab197 commit 77efdc6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- ordering in `/assets/asset/txs`, `/assets/asset/transactions` and `/epochs/{number}/stakes`
- port configuration via config option `dbSync.port`
- error in `/epochs/n/parameters` for epochs without PlutusV1/PlutusV2 cost models

Expand Down
9 changes: 8 additions & 1 deletion src/sql/assets/assets_asset_transactions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,11 @@ FROM (
END
) AS "sorted_limited"
JOIN tx ON (sorted_limited.tx_id = tx.id)
JOIN block b ON (b.id = tx.block_id)
JOIN block b ON (b.id = tx.block_id)
ORDER BY CASE
WHEN LOWER($1) = 'desc' THEN sorted_limited.tx_id
END DESC,
CASE
WHEN LOWER($1) <> 'desc'
OR $1 IS NULL THEN sorted_limited.tx_id
END ASC
9 changes: 8 additions & 1 deletion src/sql/assets/assets_asset_txs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,11 @@ FROM (
ELSE 0
END
) AS "sorted_limited"
JOIN tx ON (sorted_limited.tx_id = tx.id)
JOIN tx ON (sorted_limited.tx_id = tx.id)
ORDER BY CASE
WHEN LOWER($1) = 'desc' THEN sorted_limited.tx_id
END DESC,
CASE
WHEN LOWER($1) <> 'desc'
OR $1 IS NULL THEN sorted_limited.tx_id
END ASC
6 changes: 4 additions & 2 deletions src/sql/epochs/epochs_number_stakes.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ SELECT sa.view AS "stake_address",
ph.view AS "pool_id",
sorted_limited.amount::TEXT AS "amount" -- cast to TEXT to avoid number overflow
FROM(
SELECT es.amount AS "amount",
SELECT es.id,
es.amount AS "amount",
es.addr_id,
es.pool_id
FROM epoch_stake es
Expand All @@ -25,4 +26,5 @@ FROM(
END
) AS "sorted_limited"
JOIN pool_hash ph ON (ph.id = sorted_limited.pool_id)
JOIN stake_address sa ON (sorted_limited.addr_id = sa.id)
JOIN stake_address sa ON (sorted_limited.addr_id = sa.id)
ORDER BY sorted_limited.id ASC

0 comments on commit 77efdc6

Please sign in to comment.