From e7461c0b7a61842e3fc602898043ae66dcba40bf Mon Sep 17 00:00:00 2001 From: drethereum <71602799+drethereum@users.noreply.github.com> Date: Wed, 30 Jul 2025 12:01:05 -0600 Subject: [PATCH] reduce/dex-lookback (#522) * reduce/dex-lookback * inserted date filters --- .../defi/silver__complete_dex_swaps.sql | 70 +------------------ ...mline__hourly_prices_coingecko_history.sql | 2 + ...line__hourly_prices_coingecko_realtime.sql | 2 + ...__hourly_prices_coinmarketcap_realtime.sql | 2 + 4 files changed, 9 insertions(+), 67 deletions(-) diff --git a/models/silver/defi/silver__complete_dex_swaps.sql b/models/silver/defi/silver__complete_dex_swaps.sql index e0f95cf..6b0537d 100644 --- a/models/silver/defi/silver__complete_dex_swaps.sql +++ b/models/silver/defi/silver__complete_dex_swaps.sql @@ -479,70 +479,6 @@ WHERE ) {% endif %} ), - -{# osmosis AS ( -SELECT - 'osmosis' AS blockchain, - 'osmosis' platform, - s.block_id AS block_number, - s.block_timestamp, - s.tx_id AS tx_hash, - pool_address AS contract_address, - trader AS trader, - from_currency AS token_in, - NULL AS symbol_in, - from_amount AS amount_in_raw, - CASE - WHEN s.from_decimal IS NOT NULL THEN from_amount / power( - 10, - s.from_decimal - ) - END AS amount_in, - NULL AS amount_in_usd, - to_currency AS token_out, - NULL AS symbol_out, - to_amount AS amount_out_raw, - CASE - WHEN s.to_decimal IS NOT NULL THEN to_amount / power( - 10, - s.to_decimal - ) - END AS amount_out, - NULL AS amount_out_usd, - FALSE AS token_in_is_verified, - FALSE AS token_out_is_verified, - CONCAT( - s.tx_id, - '-', - s._BODY_INDEX - ) AS _log_id, - s.modified_timestamp AS _inserted_timestamp, - {{ dbt_utils.generate_surrogate_key(['fact_swaps_id','blockchain']) }} AS complete_dex_swaps_id, - {{ dbt_utils.generate_surrogate_key(['blockchain','block_number','platform']) }} AS _unique_key -FROM - {{ source( - 'osmosis_defi', - 'fact_swaps' - ) }} - s - LEFT JOIN {{ source( - 'osmosis_defi', - 'dim_liquidity_pools' - ) }} - p - ON s.pool_id = p.pool_id - -{% if is_incremental() and 'osmosis' not in var('HEAL_MODELS') %} -WHERE - _inserted_timestamp >= ( - SELECT - MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "24 hours") }}' - FROM - {{ this }} - ) -{% endif %} -), -#} solana AS ( SELECT 'solana' AS blockchain, @@ -580,7 +516,7 @@ solana AS ( WHERE _inserted_timestamp >= ( SELECT - MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "24 hours") }}' + MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "6 hours") }}' FROM {{ this }} ) @@ -623,7 +559,7 @@ near AS ( WHERE _inserted_timestamp >= ( SELECT - MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "24 hours") }}' + MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "6 hours") }}' FROM {{ this }} ) @@ -666,7 +602,7 @@ aptos AS ( WHERE _inserted_timestamp >= ( SELECT - MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "24 hours") }}' + MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "6 hours") }}' FROM {{ this }} ) diff --git a/models/streamline/silver/coingecko/prices/streamline__hourly_prices_coingecko_history.sql b/models/streamline/silver/coingecko/prices/streamline__hourly_prices_coingecko_history.sql index 579bc96..8a365c3 100644 --- a/models/streamline/silver/coingecko/prices/streamline__hourly_prices_coingecko_history.sql +++ b/models/streamline/silver/coingecko/prices/streamline__hourly_prices_coingecko_history.sql @@ -19,7 +19,9 @@ WITH assets AS ( MAX(_inserted_timestamp) FROM {{ ref('bronze__streamline_asset_metadata_coingecko') }} + WHERE _inserted_date >= DATEADD('day', -3, SYSDATE()) ) + AND _inserted_date >= DATEADD('day', -3, SYSDATE()) --active tokens only ), run_times AS ( diff --git a/models/streamline/silver/coingecko/prices/streamline__hourly_prices_coingecko_realtime.sql b/models/streamline/silver/coingecko/prices/streamline__hourly_prices_coingecko_realtime.sql index 87ebf63..9151766 100644 --- a/models/streamline/silver/coingecko/prices/streamline__hourly_prices_coingecko_realtime.sql +++ b/models/streamline/silver/coingecko/prices/streamline__hourly_prices_coingecko_realtime.sql @@ -19,7 +19,9 @@ WITH assets AS ( MAX(_inserted_timestamp) FROM {{ ref("bronze__streamline_asset_metadata_coingecko") }} + WHERE _inserted_date >= DATEADD('day', -3, SYSDATE()) ) + AND _inserted_date >= DATEADD('day', -3, SYSDATE()) ), calls AS ( SELECT diff --git a/models/streamline/silver/coinmarketcap/prices/streamline__hourly_prices_coinmarketcap_realtime.sql b/models/streamline/silver/coinmarketcap/prices/streamline__hourly_prices_coinmarketcap_realtime.sql index 316c795..0b7cebb 100644 --- a/models/streamline/silver/coinmarketcap/prices/streamline__hourly_prices_coinmarketcap_realtime.sql +++ b/models/streamline/silver/coinmarketcap/prices/streamline__hourly_prices_coinmarketcap_realtime.sql @@ -19,7 +19,9 @@ WITH assets AS ( MAX(_inserted_timestamp) FROM {{ ref("bronze__streamline_asset_metadata_coinmarketcap") }} + WHERE _inserted_date >= DATEADD('day', -3, SYSDATE()) ) + AND _inserted_date >= DATEADD('day', -3, SYSDATE()) ), run_times AS ( SELECT