-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding listing info to owned tokens view (#43)
- Loading branch information
Showing
3 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
migrations/2022-12-15-141928_owned_tokens_with_listing/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
24
migrations/2022-12-15-141928_owned_tokens_with_listing/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |