Skip to content

Commit

Permalink
Add listing_created_at to mb_views.nft_metadata_unburned (#90)
Browse files Browse the repository at this point in the history
* Add `listing_created_at` to `mb_views.metadata_unburned`

* Add hasura permission
  • Loading branch information
tifrel authored Aug 10, 2023
1 parent 8c0b795 commit 097be39
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ select_permissions:
- price
- currency
- listed_by
- listing_created_at
- base_uri
- content_flag
filter: {}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
drop view mb_views.nft_metadata_unburned;

create view mb_views.nft_metadata_unburned as
select md.id as metadata_id,
md.title,
md.description,
md.reference,
md.media,
md.nft_contract_id,
md.base_uri,
md.reference_blob,
md.content_flag,
t.minted_timestamp,
t.last_transfer_timestamp,
t.minter,
l.price,
l.currency,
l.listed_by
from nft_metadata md
left join lateral (
select
t.minted_timestamp,
t.last_transfer_timestamp,
t.minter
from nft_tokens t
where
t.burned_timestamp is null and t.metadata_id = md.id
order by greatest(t.minted_timestamp, t.last_transfer_timestamp) desc
limit 1
) t on true
left join lateral (
select
p.price,
p.currency,
p.listed_by
from nft_listings p
where
p.unlisted_at is null and
p.accepted_at is null and
p.invalidated_at is null and
p.metadata_id = md.id
order by p.price asc
limit 1
) l on true
where coalesce(t.last_transfer_timestamp, t.minted_timestamp) is not null;
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
drop view mb_views.nft_metadata_unburned;

create view mb_views.nft_metadata_unburned as
select md.id as metadata_id,
md.title,
md.description,
md.reference,
md.media,
md.nft_contract_id,
md.base_uri,
md.reference_blob,
md.content_flag,
t.minted_timestamp,
t.last_transfer_timestamp,
t.minter,
l.price,
l.currency,
l.listed_by,
l.created_at as listing_created_at
from nft_metadata md
left join lateral (
select
t.minted_timestamp,
t.last_transfer_timestamp,
t.minter
from nft_tokens t
where
t.burned_timestamp is null and t.metadata_id = md.id
order by greatest(t.minted_timestamp, t.last_transfer_timestamp) desc
limit 1
) t on true
left join lateral (
select
p.price,
p.currency,
p.listed_by,
p.created_at
from nft_listings p
where
p.unlisted_at is null and
p.accepted_at is null and
p.invalidated_at is null and
p.metadata_id = md.id
order by p.price asc
limit 1
) l on true
where coalesce(t.last_transfer_timestamp, t.minted_timestamp) is not null;

0 comments on commit 097be39

Please sign in to comment.