mirror of
https://github.com/FlipsideCrypto/external-models.git
synced 2026-02-06 13:17:03 +00:00
parent
118d328feb
commit
31f8e047c1
@ -1,88 +0,0 @@
|
||||
{{
|
||||
config(
|
||||
materialized = 'view',
|
||||
tags = ['streamline_view']
|
||||
)
|
||||
}}
|
||||
|
||||
-- Chains: SCROLL, SUI, FTM, LINEA, RONIN (Flipside Supported)
|
||||
-- Address: LINEA, SCROLL, RONIN (Only `newActiveAddresses`), FTM
|
||||
-- Stats: FTM
|
||||
|
||||
WITH metrics AS (
|
||||
-- Addresses count metrics (no date params)
|
||||
SELECT
|
||||
'Linea' AS blockchain,
|
||||
'LINEA' AS chain_short_name,
|
||||
'address_count' AS metric,
|
||||
'https://www.oklink.com/api/v5/explorer/blockchain/address' AS endpoint,
|
||||
FALSE AS historical_data,
|
||||
'Count of addresses on Linea blockchain' AS description
|
||||
UNION ALL
|
||||
SELECT
|
||||
'Scroll' AS blockchain,
|
||||
'SCROLL' AS chain_short_name,
|
||||
'address_count' AS metric,
|
||||
'https://www.oklink.com/api/v5/explorer/blockchain/address' AS endpoint,
|
||||
FALSE AS historical_data,
|
||||
'Count of addresses on Scroll blockchain' AS description
|
||||
UNION ALL
|
||||
-- Only `activeAddresses`/`newActiveAddresses` available for Ronin
|
||||
SELECT
|
||||
'Ronin' AS blockchain,
|
||||
'RONIN' AS chain_short_name,
|
||||
'address_count' AS metric,
|
||||
'https://www.oklink.com/api/v5/explorer/blockchain/address' AS endpoint,
|
||||
FALSE AS historical_data,
|
||||
'Count of addresses on Ronin blockchain' AS description
|
||||
UNION ALL
|
||||
SELECT
|
||||
'Fantom' AS blockchain,
|
||||
'FTM' AS chain_short_name,
|
||||
'address_count' AS metric,
|
||||
'https://www.oklink.com/api/v5/explorer/blockchain/address' AS endpoint,
|
||||
FALSE AS historical_data,
|
||||
'Count of addresses on Ronin blockchain' AS description
|
||||
UNION ALL
|
||||
-- Blockchain stats metrics (can use StartTime and endTime)
|
||||
SELECT
|
||||
'Fantom' AS blockchain,
|
||||
'FTM' AS chain_short_name,
|
||||
'blockchain_stats' AS metric,
|
||||
'https://www.oklink.com/api/v5/explorer/blockchain/stats' AS endpoint,
|
||||
TRUE AS historical_data,
|
||||
'Blockchain statistics for Fantom' AS description
|
||||
)
|
||||
|
||||
SELECT
|
||||
date_day,
|
||||
blockchain,
|
||||
metric,
|
||||
endpoint,
|
||||
CASE
|
||||
WHEN metric IN ('address_count') THEN
|
||||
-- For endpoints without look-back functionality (i.e. address)
|
||||
OBJECT_CONSTRUCT(
|
||||
'chainShortName', chain_short_name
|
||||
)
|
||||
ELSE
|
||||
-- For endpoints with look-back functionality (i.e. stats)
|
||||
OBJECT_CONSTRUCT(
|
||||
'chainShortName', chain_short_name,
|
||||
'startTime', ((DATE_PART('EPOCH', date_day)) * 1000)::STRING,
|
||||
'endTime', ((DATE_PART('EPOCH', DATEADD(SECOND, -1, DATEADD(DAY, 1, date_day)))) * 1000)::STRING,
|
||||
'limit', '1',
|
||||
'page', '1'
|
||||
)
|
||||
END AS variables,
|
||||
description
|
||||
FROM
|
||||
{{ source(
|
||||
'crosschain_core',
|
||||
'dim_dates'
|
||||
) }}
|
||||
CROSS JOIN metrics
|
||||
WHERE
|
||||
(metric = 'address_count' AND date_day = CURRENT_DATE())
|
||||
OR
|
||||
(metric = 'blockchain_stats' AND date_day >= '2025-01-01' AND date_day < CURRENT_DATE())
|
||||
@ -1,53 +0,0 @@
|
||||
{{ config (
|
||||
materialized = "view",
|
||||
post_hook = fsc_utils.if_data_call_function_v2(
|
||||
func = 'streamline.udf_bulk_rest_api_v2',
|
||||
target = "{{this.schema}}.{{this.identifier}}",
|
||||
params = {
|
||||
"external_table": "oklink",
|
||||
"sql_limit": "1",
|
||||
"producer_batch_size": "1",
|
||||
"worker_batch_size": "1",
|
||||
"async_concurrent_requests": "1",
|
||||
"sql_source": "{{this.identifier}}",
|
||||
"order_by_column": "date_day",
|
||||
"request_delay_ms": "1000"}
|
||||
),
|
||||
tags = ['streamline_realtime']
|
||||
) }}
|
||||
|
||||
WITH metrics AS (
|
||||
SELECT
|
||||
date_day,
|
||||
blockchain,
|
||||
metric,
|
||||
CASE
|
||||
WHEN metric = 'address_count' THEN
|
||||
endpoint || '?chainShortName=' || variables:chainShortName
|
||||
WHEN metric = 'blockchain_stats' THEN
|
||||
endpoint || '?chainShortName=' || variables:chainShortName ||
|
||||
'&startTime=' || variables:startTime ||
|
||||
'&endTime=' || variables:endTime ||
|
||||
'&limit=' || variables:limit ||
|
||||
'&page=' || variables:page
|
||||
END AS full_endpoint
|
||||
FROM
|
||||
{{ ref("streamline__oklink_metrics") }}
|
||||
)
|
||||
SELECT
|
||||
TO_NUMBER(to_char(date_day, 'YYYYMMDD')) AS date_day,
|
||||
blockchain,
|
||||
metric,
|
||||
TO_NUMBER(to_char(SYSDATE()::DATE, 'YYYYMMDD')) AS partition_key,
|
||||
livequery.live.udf_api(
|
||||
'GET',
|
||||
full_endpoint,
|
||||
OBJECT_CONSTRUCT(
|
||||
'Content-Type', 'application/json',
|
||||
'Ok-Access-Key', '{Authentication}'
|
||||
),
|
||||
NULL,
|
||||
'Vault/prod/oklink'
|
||||
) AS request
|
||||
FROM
|
||||
metrics
|
||||
Loading…
Reference in New Issue
Block a user