Skip to content

Commit

Permalink
Merge pull request #52 from Mintbase/undo-rows-use-contract-list-view
Browse files Browse the repository at this point in the history
feat: 🗃️ Undo row num, new active listings by contract view
  • Loading branch information
cif authored Jan 20, 2023
2 parents 754c4bb + 774382a commit ecf78d9
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 71 deletions.
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
1 change: 1 addition & 0 deletions hasura/metadata/databases/minterop/tables/tables.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
- "!include analytics_tmp_referrer_earnings.yaml"
- "!include mb_views_active_listings_rollup.yaml"
- "!include mb_views_active_listings.yaml"
- "!include mb_views_active_listings_by_contract.yaml"
- "!include mb_views_auctions_with_offer.yaml"
- "!include mb_views_nft_activities.yaml"
- "!include mb_views_nft_activities_rollup.yaml"
Expand Down
35 changes: 0 additions & 35 deletions migrations/2023-01-19-150207_add-meta-row-num/down.sql

This file was deleted.

36 changes: 0 additions & 36 deletions migrations/2023-01-19-150207_add-meta-row-num/up.sql

This file was deleted.

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 migrations/2023-01-20-103450_add-listings-by-contract/up.sql
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

0 comments on commit ecf78d9

Please sign in to comment.