-
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.
Merge pull request #52 from Mintbase/undo-rows-use-contract-list-view
feat: 🗃️ Undo row num, new active listings by contract view
- Loading branch information
Showing
6 changed files
with
90 additions
and
71 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
hasura/metadata/databases/minterop/tables/mb_views_active_listings_by_contract.yaml
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,45 @@ | ||
table: | ||
schema: mb_views | ||
name: active_listings_by_contract | ||
object_relationships: | ||
- name: token | ||
using: | ||
manual_configuration: | ||
column_mapping: | ||
nft_contract_id: nft_contract_id | ||
token_id: token_id | ||
insertion_order: null | ||
remote_table: | ||
name: nft_tokens | ||
schema: mb_views | ||
array_relationships: | ||
- name: offers | ||
using: | ||
manual_configuration: | ||
column_mapping: | ||
approval_id: approval_id | ||
market_id: market_id | ||
nft_contract_id: nft_contract_id | ||
token_id: token_id | ||
insertion_order: null | ||
remote_table: | ||
name: nft_offers | ||
schema: public | ||
select_permissions: | ||
- role: anonymous | ||
permission: | ||
columns: | ||
- nft_contract_id | ||
- base_uri | ||
- price | ||
- created_at | ||
- metadata_id | ||
- token_id | ||
- title | ||
- media | ||
- market_id | ||
- approval_id | ||
- listed_by | ||
- total_listings | ||
filter: {} | ||
allow_aggregations: true |
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 @@ | ||
drop view mb_views.active_listings_by_contract; |
43 changes: 43 additions & 0 deletions
43
migrations/2023-01-20-103450_add-listings-by-contract/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,43 @@ | ||
-- add listings by contract view | ||
-- todo: neat things like adding attributes to this view, geolocation etc. etc. | ||
create view mb_views.active_listings_by_contract as | ||
select | ||
c.id as nft_contract_id, | ||
c.base_uri, | ||
cl.price, | ||
cl.created_at, | ||
cl.metadata_id, | ||
cl.token_id, | ||
cl.market_id, | ||
cl.approval_id, | ||
cl.listed_by, | ||
tl.total_listings, | ||
cmd.title, | ||
cmd.media | ||
from nft_contracts c | ||
left join lateral ( | ||
select | ||
l.price, | ||
l.created_at, | ||
l.token_id, | ||
l.metadata_id, | ||
l.market_id, | ||
l.approval_id, | ||
l.listed_by | ||
from nft_listings l | ||
where l.nft_contract_id = c.id and l.unlisted_at is null and l.accepted_at is null and l.invalidated_at is null | ||
order by l.created_at desc | ||
limit 3 | ||
) cl on true | ||
left join lateral ( | ||
select count(*) as total_listings | ||
from nft_listings l | ||
where l.nft_contract_id = c.id and l.unlisted_at is null and l.accepted_at is null and l.invalidated_at is null | ||
) tl on true | ||
left join lateral ( | ||
select m.title, m.media -- future! select media type, other ref json fields of interest | ||
from nft_metadata m | ||
where cl.metadata_id = m.id and c.id = m.nft_contract_id | ||
limit 1 | ||
) cmd on true | ||
where cl.price is not null; -- omit null lateral appendages |