-
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.
* Activities rollup * Adding token_ids aggregation
- Loading branch information
Showing
3 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
hasura/metadata/databases/minterop/tables/mb_views_nft_activities_rollup.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,38 @@ | ||
table: | ||
schema: mb_views | ||
name: nft_activities_rollup | ||
object_relationships: | ||
- name: nft_contract | ||
using: | ||
manual_configuration: | ||
remote_table: | ||
schema: public | ||
name: nft_contracts | ||
insertion_order: null | ||
column_mapping: | ||
nft_contract_id: id | ||
select_permissions: | ||
- role: anonymous | ||
permission: | ||
columns: | ||
- tx_sender | ||
- timestamp | ||
- nft_contract_id | ||
- kind | ||
- action_sender | ||
- action_receiver | ||
- price | ||
- reference | ||
- reference_blob | ||
- id as metadata_id | ||
- title | ||
- description | ||
- media | ||
- media_hash | ||
- extra | ||
- content_flag | ||
- receipt_id | ||
- count | ||
- token_ids | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
drop view mb_views.nft_activities_rollup; | ||
drop index nft_activities_receipt_id_index; |
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,65 @@ | ||
create view mb_views.nft_activities_rollup as | ||
select | ||
a.tx_sender, | ||
a.timestamp, | ||
a.nft_contract_id, | ||
a.kind, | ||
a.action_sender, | ||
a.action_receiver, | ||
a.price, | ||
m.reference, | ||
m.reference_blob, | ||
m.id as metadata_id, | ||
m.title, | ||
m.description, | ||
m.media, | ||
m.media_hash, | ||
m.extra, | ||
m.content_flag, | ||
a.receipt_id, | ||
a.count, | ||
a.token_ids | ||
from ( | ||
select | ||
count(*), | ||
tx_sender, | ||
timestamp, | ||
a_.nft_contract_id, | ||
kind, | ||
action_sender, | ||
action_receiver, | ||
price, | ||
receipt_id, | ||
metadata_id, | ||
array_agg(a_.token_id) token_ids | ||
from ( | ||
select | ||
a__.nft_contract_id, | ||
a__.token_id, | ||
tx_sender, | ||
timestamp, | ||
kind, | ||
action_sender, | ||
action_receiver, | ||
price, | ||
receipt_id, | ||
metadata_id | ||
from nft_activities a__ | ||
left join nft_tokens t | ||
on a__.nft_contract_id = t.nft_contract_id and a__.token_id = t.token_id | ||
) a_ | ||
group by | ||
receipt_id, | ||
tx_sender, | ||
timestamp, | ||
nft_contract_id, | ||
kind, | ||
action_sender, | ||
action_receiver, | ||
price, | ||
metadata_id | ||
) a | ||
left join nft_metadata m | ||
on a.metadata_id = m.id; | ||
|
||
create index nft_activities_receipt_id_index on nft_activities(receipt_id); |