mirror of
https://github.com/FlipsideCrypto/flow-models.git
synced 2026-02-06 11:47:00 +00:00
AN-2668 topshot packs (#103)
* ts packs * alpha version topshot packs * beta schema
This commit is contained in:
parent
1196f4f0c5
commit
d3c20cd76b
28
models/beta/beta__ez_nft_topshot_packs.sql
Normal file
28
models/beta/beta__ez_nft_topshot_packs.sql
Normal file
@ -0,0 +1,28 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
tags = ['nft', 'ez']
|
||||
) }}
|
||||
|
||||
WITH silver_nfts AS (
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
{{ ref('silver__nft_topshot_pack_sales') }}
|
||||
),
|
||||
gold_nfts AS (
|
||||
SELECT
|
||||
tx_id,
|
||||
block_height,
|
||||
block_timestamp,
|
||||
marketplace,
|
||||
nft_id,
|
||||
buyer,
|
||||
tx_succeeded
|
||||
FROM
|
||||
silver_nfts
|
||||
)
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
gold_nfts
|
||||
85
models/beta/beta__ez_nft_topshot_packs.yml
Normal file
85
models/beta/beta__ez_nft_topshot_packs.yml
Normal file
@ -0,0 +1,85 @@
|
||||
version: 2
|
||||
|
||||
models:
|
||||
- name: beta__ez_nft_topshot_packs
|
||||
description: |-
|
||||
This ez_ view contains the NBA TopShot nfts transfers related to rips. These are assumed to be packs that were purchased and opened. This is an alpha version and does not have sale price or pack name at this time.
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- tx_id
|
||||
- buyer
|
||||
- nft_id
|
||||
|
||||
columns:
|
||||
- name: TX_ID
|
||||
description: "{{ doc('tx_id') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: BLOCK_HEIGHT
|
||||
description: "{{ doc('block_height') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: "{{ doc('block_timestamp') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 1
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_NTZ
|
||||
|
||||
- name: MARKETPLACE
|
||||
description: "{{ doc('marketplace') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
|
||||
- name: NFT_ID
|
||||
description: "{{ doc('nft_id') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
- NUMBER
|
||||
|
||||
- name: BUYER
|
||||
description: "{{ doc('buyer') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: SELLER
|
||||
description: "{{ doc('seller') }}"
|
||||
|
||||
|
||||
|
||||
- name: TX_SUCCEEDED
|
||||
description: "{{ doc('tx_succeeded') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- BOOLEAN
|
||||
|
||||
66
models/silver/silver__nft_topshot_pack_sales.sql
Normal file
66
models/silver/silver__nft_topshot_pack_sales.sql
Normal file
@ -0,0 +1,66 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'merge',
|
||||
cluster_by = ['_inserted_timestamp::DATE'],
|
||||
unique_key = ['tx_id','nft_id'],
|
||||
tags = ['nft']
|
||||
) }}
|
||||
|
||||
WITH silver_events AS (
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
{{ ref('silver__events_final') }}
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
nft_txs AS (
|
||||
SELECT
|
||||
tx_id,
|
||||
event_index,
|
||||
block_height,
|
||||
block_timestamp,
|
||||
tx_succeeded,
|
||||
event_data :id :: INT AS nft_id,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
silver_events
|
||||
WHERE
|
||||
event_data :from = '0xe1f2a091f7bb5245'
|
||||
AND event_contract = 'A.0b2a3299cc857e29.TopShot'
|
||||
)
|
||||
SELECT
|
||||
A.tx_id,
|
||||
A.block_height,
|
||||
A.block_timestamp,
|
||||
'topshot pack' AS marketplace,
|
||||
NULL AS nft_collection,
|
||||
A.nft_id,
|
||||
b.event_data :to :: STRING buyer,
|
||||
NULL AS seller,
|
||||
NULL price,
|
||||
NULL currency,
|
||||
A.tx_succeeded,
|
||||
NULL AS tokenflow,
|
||||
NULL AS counterparties,
|
||||
MD5(
|
||||
CAST(COALESCE(CAST(A.tx_id AS VARCHAR), '') AS VARCHAR)
|
||||
) AS pack_id,
|
||||
A._inserted_timestamp
|
||||
FROM
|
||||
nft_txs A
|
||||
JOIN silver_events b
|
||||
ON A.tx_id = b.tx_id
|
||||
AND A.nft_id = b.event_data :id :: INT
|
||||
WHERE
|
||||
event_data :to IS NOT NULL
|
||||
AND A.event_index <> b.event_index
|
||||
105
models/silver/silver__nft_topshot_pack_sales.yml
Normal file
105
models/silver/silver__nft_topshot_pack_sales.yml
Normal file
@ -0,0 +1,105 @@
|
||||
version: 2
|
||||
|
||||
models:
|
||||
- name: silver__nft_topshot_pack_sales
|
||||
description: |-
|
||||
TopShot pack sales
|
||||
|
||||
columns:
|
||||
- name: tx_id
|
||||
description: "{{ doc('tx_id') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: block_height
|
||||
description: "{{ doc('block_height') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
|
||||
- name: block_timestamp
|
||||
description: "{{ doc('block_timestamp') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 1
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_NTZ
|
||||
|
||||
- name: marketplace
|
||||
description: "{{ doc('marketplace') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: nft_collection
|
||||
description: "{{ doc('nft_collection') }}"
|
||||
|
||||
- name: nft_id
|
||||
description: "{{ doc('nft_id') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
- NUMBER
|
||||
|
||||
- name: buyer
|
||||
description: "{{ doc('buyer') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: seller
|
||||
description: "{{ doc('seller') }}"
|
||||
|
||||
|
||||
- name: price
|
||||
description: "{{ doc('price') }}"
|
||||
tests:
|
||||
|
||||
- name: currency
|
||||
description: "{{ doc('currency') }}"
|
||||
|
||||
- name: tx_succeeded
|
||||
description: "{{ doc('tx_succeeded') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- BOOLEAN
|
||||
|
||||
- name: _ingested_at
|
||||
description: "{{ doc('_ingested_at') }}"
|
||||
|
||||
- name: tokenflow
|
||||
description: "{{ doc('tokenflow') }}"
|
||||
|
||||
|
||||
- name: counterparties
|
||||
description: "{{ doc('counterparties') }}"
|
||||
|
||||
|
||||
- name: _inserted_timestamp
|
||||
description: "{{ doc('_inserted_timestamp') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_NTZ
|
||||
Loading…
Reference in New Issue
Block a user