AN-6321 Aptos Lync (#123)

This commit is contained in:
eric-laurello 2025-05-29 13:35:59 -04:00 committed by GitHub
parent f06ac08157
commit c7491a2303
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 136 additions and 1 deletions

View File

@ -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]

View 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

View 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

View 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'