Skip to content

Commit

Permalink
Merge pull request #140 from blockfrost/1000101/2402/assets_asset_opt…
Browse files Browse the repository at this point in the history
…imization

feat(assets): improve asset query
  • Loading branch information
vladimirvolek authored Feb 23, 2024
2 parents 1873734 + ec48c4e commit 0cab197
Show file tree
Hide file tree
Showing 44 changed files with 30 additions and 435 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed .yarn/cache/spex-npm-3.3.0-833f63faad-c2797eae65.zip
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- improved `/assets/:asset` performance for assets with many mint txs
- node_modules
- yarn
- updated vitest
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"rimraf": "^5.0.1"
},
"devDependencies": {
"@blockfrost/blockfrost-tests": "1.11.0",
"@types/blake2b": "^2.1.3",
"@types/config": "3.3.1",
"@types/express": "^4.17.17",
Expand Down
22 changes: 15 additions & 7 deletions src/sql/assets/assets_asset.sql
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
WITH queried_metadata AS (
WITH queried_asset AS (
SELECT id AS "asset_id"
FROM multi_asset ma
WHERE (
encode(ma.policy, 'hex') || encode(ma.name, 'hex')
) = $1
),
queried_metadata AS (
SELECT txm.json AS "onchain_metadata",
encode(txm.bytes, 'hex') AS "onchain_metadata_cbor"
FROM tx_metadata txm
WHERE txm.tx_id = (
SELECT MAX(txmmax.tx_id)
FROM ma_tx_mint mtmmax
JOIN multi_asset ma ON (mtmmax.ident = ma.id)
JOIN tx_metadata txmmax ON (mtmmax.tx_id = txmmax.tx_id)
WHERE txmmax.key = 721
WHERE mtmmax.id = (
SELECT asset_id
FROM queried_asset
)
AND txmmax.key = 721
AND quantity > 0
AND (
encode(ma.policy, 'hex') || encode(ma.name, 'hex')
) = $1
)
AND txm.key = 721
)
Expand All @@ -23,7 +30,8 @@ SELECT (
WHEN encode(ma.name, 'hex') <> '' THEN encode(ma.name, 'hex')
ELSE null
END AS "asset_name",
SUM(mtm.quantity)::TEXT AS "quantity", -- cast to TEXT to avoid number overflow
SUM(mtm.quantity)::TEXT AS "quantity",
-- cast to TEXT to avoid number overflow
(
SELECT encode(tx.hash, 'hex')
FROM tx
Expand Down
63 changes: 12 additions & 51 deletions yarn-project.nix

Large diffs are not rendered by default.

Loading

0 comments on commit 0cab197

Please sign in to comment.