Skip to content

Commit

Permalink
Adding listing info to owned tokens view (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
tifrel authored Dec 15, 2022
1 parent c302922 commit f05a730
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,10 @@ select_permissions:
- starts_at
- updated_at
- metadata_content_flag
- price
- currency
- listing_kind
- market_id
- listing_approval_id
filter: {}
allow_aggregations: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
drop view mb_views.nft_owned_tokens;
create view mb_views.nft_owned_tokens as
select * from mb_views.nft_tokens
where burned_timestamp is null
order by greatest(last_transfer_timestamp, minted_timestamp) desc nulls last;
24 changes: 24 additions & 0 deletions migrations/2022-12-15-141928_owned_tokens_with_listing/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
drop view mb_views.nft_owned_tokens;
create view mb_views.nft_owned_tokens as
select * from (
select * from mb_views.nft_tokens
where burned_timestamp is null
order by greatest(last_transfer_timestamp, minted_timestamp) desc nulls last
) t
left join lateral (
select
price,
currency,
kind as listing_kind,
market_id,
approval_id as listing_approval_id
from nft_listings l
where
l.unlisted_at is null and
l.accepted_at is null and
l.invalidated_at is null and
l.nft_contract_id = t.nft_contract_id and
l.token_id = t.token_id
order by l.price asc
limit 1
) l on true;

0 comments on commit f05a730

Please sign in to comment.