flow-models/tests/tests__block_tx_count_recency.sql
Jack Forgash d28d09f53e
AN-3939/add fix gap logic and obs models tests (#195)
* add fix gap logic and obs models tests

* block height recency test on bitquery table

* add tag

* upd workflow

* explicit cast as int
2023-09-15 13:45:28 -06:00

26 lines
482 B
SQL

{{ config(
severity = 'error',
tags = ['observability']
) }}
WITH check_lag AS (
SELECT
{{ target.database }}.streamline.udf_get_chainhead() AS chainhead,
(
SELECT
MAX(block_height)
FROM
{{ ref('silver_observability__block_tx_count') }}
) AS max_height,
(
chainhead - max_height < 25000
) AS is_recent
)
SELECT
*
FROM
check_lag
WHERE
NOT is_recent