Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(assets): improve asset query #140

Merged
merged 4 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading