adding gold views

This commit is contained in:
WHYTEWYLL 2023-11-08 16:01:11 -03:00
parent e283e9e794
commit 1a5c74d2f4
12 changed files with 157 additions and 38 deletions

View File

@ -0,0 +1,5 @@
{% docs all_transfers %}
"The total count of 'nft_transfer' transactions."
{% enddocs %}

View File

@ -0,0 +1,5 @@
{% docs mint_count %}
"The count of transactions where the method_name indicates a minting event rather than a transfer."
{% enddocs %}

View File

@ -0,0 +1,5 @@
{% docs owner_count %}
"The count of distinct owners that have interacted with the receiver's tokens."
{% enddocs %}

View File

@ -0,0 +1,5 @@
{% docs tokens_count %}
"The count of unique tokens that have been received by the receiver_id."
{% enddocs %}

View File

@ -0,0 +1,17 @@
{{ config(
materialized = 'view',
secure = false,
tags = ['atlas']
) }}
WITH 30_trailing AS (
SELECT
day,
txns
FROM {{ ref('silver__atlas_nft_transactions') }}
)
SELECT
*
FROM 30_trailing

View File

@ -0,0 +1,13 @@
version: 2
models:
- name: atlas__fact_nft_30_trailing
description: |-
Summary of NFT transactions from the 'silver__atlas_nft_transactions' table. It provides a daily count of transactions, accounting for a 29-day lookback period for each day within the specified date range.
columns:
- name: day
description: "{{ doc('date')}}"
- name: txns
description: "{{ doc('tx_count')}}"

View File

@ -0,0 +1,22 @@
{{ config(
materialized = 'view',
secure = false,
tags = ['atlas']
) }}
WITH nft_detailed AS (
SELECT
day,
receiver_id,
tokens,
all_transfers,
owners,
transactions,
mints
FROM {{ ref('silver__atlas_nft_detailed') }}
)
SELECT
*
FROM nft_detailed

View File

@ -0,0 +1,31 @@
version: 2
models:
- name: atlas__fact_nft_detailed
description: |-
Oveeview of NFT transactions in NEAR.
columns:
- name: action_id
description: "A unique identifier for the action, constructed as a concatenation of the day and receiver_id."
- name: day
description: "{{ doc('date')}}"
- name: receiver_id
description: "{{ doc('tx_receiver')}}"
- name: tokens
description: "{{ doc('tokens_count')}}"
- name: all_transfers
description: "{{ doc('all_transfers')}}"
- name: owners
description: "{{ doc('owner_count')}}"
- name: transactions
description: "{{ doc('tx_count')}}"
- name: mints
description: "{{ doc('mint_count')}}"

View File

@ -0,0 +1,23 @@
{{ config(
materialized = 'view',
secure = false,
tags = ['atlas']
) }}
WITH nft_data AS (
SELECT
receiver_id,
tokens,
ransfers_24h,
transfers_3d,
all_transfers,
owners,
transactions,
mints
FROM {{ ref('silver__atlas_nft_table') }}
)
select
*
from nft_data

View File

@ -0,0 +1,31 @@
version: 2
models:
- name: atlas__fact_nft_table
description: |-
NFT transaction activities by receiver_id. It includes counts of unique tokens, transfers within the last 24 hours and 3 days, all transfers, unique owners, total transactions, and minting events.
columns:
- name: receiver_id
description: "{ { doc('receiver_id')}}"
- name: tokens
description: "{{ doc('tokens_count')}}"
- name: transfers_24h
description: "The count of 'nft_transfer' transactions that occurred in the last 24 hours."
- name: transfers_3d
description: "The count of 'nft_transfer' transactions that occurred in the last 3 days."
- name: all_transfers
description: "{{ doc('all_transfers')}}"
- name: owners
description: "{{ doc('owner_count')}}"
- name: transactions
description: "{{ doc('tx_count')}}"
- name: mints
description: "{{ doc('mint_count')}

View File

@ -1,38 +0,0 @@
{{ config(
materialized = 'incremental',
unique_key = 'day',
incremental_strategy = 'delete+insert',
tags = ['atlas']
) }}
WITH date_range AS (
SELECT
date_day as day
FROM {{ ref('silver__dates') }}
WHERE
{% if is_incremental() %}
date_day >= SYSDATE() - INTERVAL '3 DAY'
{% else %}
date_day >= '2021-01-01' -- first day of data
{% endif %}
AND date_day <= SYSDATE()::DATE
)
SELECT day,
COUNT(DISTINCT tx_signer) - COUNT(DISTINCT CASE WHEN first_tx >= day - INTERVAL '30 Days' AND first_tx < day THEN wallet END) AS Returning_MAAs,
COUNT(DISTINCT CASE WHEN first_tx >= day - INTERVAL '30 Days' AND first_tx < day THEN wallet END) AS New_MAAs,
COUNT(DISTINCT tx_signer) AS MAAs
FROM date_range a
LEFT OUTER JOIN (SELECT DISTINCT tx_signer, block_timestamp::date AS active_day
FROM {{ ref('silver__streamline_transactions_final') }}) b
ON active_day >= day - INTERVAL '30 DAYS'
AND active_day < day
JOIN (SELECT tx_signer AS wallet, MIN(block_timestamp) AS first_tx FROM {{ ref('silver__streamline_transactions_final') }} tr GROUP BY 1) c
ON b.tx_signer = c.wallet
GROUP BY 1
ORDER BY 1 DESC
-- 4.20 Mins all
-- 2.5 mins incremental