mirror of
https://github.com/FlipsideCrypto/external-models.git
synced 2026-02-06 10:46:48 +00:00
basic LQ model and silver for aptos lync
This commit is contained in:
parent
f06ac08157
commit
d0b0b02d73
2
.github/workflows/dbt_run_daily.yml
vendored
2
.github/workflows/dbt_run_daily.yml
vendored
@ -44,7 +44,7 @@ jobs:
|
||||
dbt deps
|
||||
- name: Run DBT Jobs
|
||||
run: |
|
||||
dbt run -m external_models,tag:defillama external_models,tag:deepnftvalue external_models,tag:core external_models,tag:blast external_models,tag:polymarket external_models,tag:bitquery external_models,tag:oklink external_models,tag:artemis --exclude models/defillama/bronze/bronze__defillama_stablecoin_supply.sql+
|
||||
dbt run -m external_models,tag:defillama external_models,tag:deepnftvalue external_models,tag:core external_models,tag:blast external_models,tag:polymarket external_models,tag:bitquery external_models,tag:oklink external_models,tag:artemis external_models,tag:aptos_gas --exclude models/defillama/bronze/bronze__defillama_stablecoin_supply.sql+
|
||||
|
||||
notify-failure:
|
||||
needs: [run_dbt_jobs]
|
||||
|
||||
53
models/aptos_gas/lync/bronze_aptos__lync_data.sql
Normal file
53
models/aptos_gas/lync/bronze_aptos__lync_data.sql
Normal file
@ -0,0 +1,53 @@
|
||||
{{ config (
|
||||
materialized = "incremental",
|
||||
tags = ['aptos_gas'],
|
||||
) }}
|
||||
|
||||
WITH paths AS (
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
VALUES
|
||||
(
|
||||
'total-transactions',
|
||||
'Total Transactions'
|
||||
),
|
||||
(
|
||||
'recurring-users',
|
||||
'Total Recurring Users'
|
||||
),
|
||||
(
|
||||
'retention',
|
||||
'Total Retention Users'
|
||||
),
|
||||
(
|
||||
'gas-consumed',
|
||||
'Total Gas Consumed'
|
||||
),
|
||||
(
|
||||
'accounts-created',
|
||||
'Total Accounts Created'
|
||||
),
|
||||
(
|
||||
'accounts-creation-gas-used',
|
||||
'Total Gas Consumed in Account Creation'
|
||||
) AS t(
|
||||
suffix,
|
||||
metric
|
||||
)
|
||||
)
|
||||
SELECT
|
||||
metric,
|
||||
{{ target.database }}.live.udf_api(
|
||||
'GET',
|
||||
'{Service}/api/v1/analytics/' || suffix || '?period=daily&type=global',
|
||||
OBJECT_CONSTRUCT(),
|
||||
OBJECT_CONSTRUCT(),
|
||||
'Vault/prod/external/aptos/lync'
|
||||
) AS DATA,
|
||||
SYSDATE() AS inserted_timestamp,
|
||||
SYSDATE() AS modified_timestamp,
|
||||
'{{ invocation_id }}' AS _invocation_id
|
||||
FROM
|
||||
paths
|
||||
45
models/aptos_gas/lync/silver_aptos__lync.sql
Normal file
45
models/aptos_gas/lync/silver_aptos__lync.sql
Normal file
@ -0,0 +1,45 @@
|
||||
{{ config (
|
||||
materialized = "incremental",
|
||||
unique_key = ['metric','metric_date'],
|
||||
tags = ['aptos_gas'],
|
||||
) }}
|
||||
|
||||
WITH base AS (
|
||||
|
||||
SELECT
|
||||
metric,
|
||||
DATA,
|
||||
inserted_timestamp
|
||||
FROM
|
||||
{{ ref('bronze_aptos__lync_data') }}
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
modified_timestamp >= (
|
||||
SELECT
|
||||
MAX(modified_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
)
|
||||
SELECT
|
||||
A.metric,
|
||||
b.value :time_stamp :: DATE AS metric_date,
|
||||
b.value :count :: bigint AS metric_count,
|
||||
b.value :amount :: FLOAT AS metric_amount,
|
||||
b.value :amountInUSD :: FLOAT AS metric_amount_in_usd,
|
||||
{{ dbt_utils.generate_surrogate_key([ 'metric', 'metric_date']) }} AS artemis_id,
|
||||
SYSDATE() AS inserted_timestamp,
|
||||
SYSDATE() AS modified_timestamp,
|
||||
'{{ invocation_id }}' AS _invocation_id
|
||||
FROM
|
||||
base A,
|
||||
LATERAL FLATTEN(
|
||||
input => A.data :data :data :result
|
||||
) b qualify ROW_NUMBER() over (
|
||||
PARTITION BY A.metric,
|
||||
b.value :time_stamp :: DATE
|
||||
ORDER BY
|
||||
inserted_timestamp DESC
|
||||
) = 1
|
||||
37
models/aptos_gas/lync/silver_aptos__lync.yml
Normal file
37
models/aptos_gas/lync/silver_aptos__lync.yml
Normal file
@ -0,0 +1,37 @@
|
||||
version: 2
|
||||
|
||||
models:
|
||||
- name: silver_aptos__lync
|
||||
description: "Lyncwold paymaster data"
|
||||
columns:
|
||||
- name: metric
|
||||
description: "The metric name"
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: metric_date
|
||||
description: "The date of the metric measurement"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 2
|
||||
|
||||
- name: metric_count
|
||||
description: "Reported metric count"
|
||||
tests:
|
||||
- not_null:
|
||||
where: metric <> 'Total Gas Consumed'
|
||||
|
||||
- name: metric_amount
|
||||
description: "Reported metric amount"
|
||||
tests:
|
||||
- not_null:
|
||||
where: metric = 'Total Gas Consumed'
|
||||
|
||||
- name: metric_amount_in_usd
|
||||
description: "Reported metric amount in USD"
|
||||
tests:
|
||||
- not_null:
|
||||
where: metric = 'Total Gas Consumed'
|
||||
|
||||
Loading…
Reference in New Issue
Block a user