diff --git a/spellbook/models/ens/ens_ethereum_sources.yml b/spellbook/models/ens/ens_ethereum_sources.yml index e5a1e05fdf8..c2462a204c4 100644 --- a/spellbook/models/ens/ens_ethereum_sources.yml +++ b/spellbook/models/ens/ens_ethereum_sources.yml @@ -3,26 +3,42 @@ version: 2 sources: - name: ethereumnameservice_ethereum freshness: - warn_after: { count: 12, period: hour } - error_after: { count: 24, period: hour } tables: - name: BaseRegistrarImplementation_evt_NameRegistered + freshness: + warn_after: { count: 12, period: hour } + error_after: { count: 24, period: hour } loaded_at_field: evt_block_time - name: BaseRegistrarImplementation_evt_NameRenewed + freshness: + warn_after: { count: 12, period: hour } + error_after: { count: 24, period: hour } loaded_at_field: evt_block_time - name: ETHRegistrarController_1_evt_NameRegistered loaded_at_field: evt_block_time - name: ETHRegistrarController_2_evt_NameRegistered loaded_at_field: evt_block_time - name: ETHRegistrarController_3_evt_NameRegistered + freshness: + warn_after: { count: 12, period: hour } + error_after: { count: 24, period: hour } loaded_at_field: evt_block_time - name: ENSRegistry_evt_NewOwner + freshness: + warn_after: { count: 12, period: hour } + error_after: { count: 24, period: hour } loaded_at_field: evt_block_time - name: ENSRegistryWithFallback_evt_NewOwner + freshness: + warn_after: { count: 12, period: hour } + error_after: { count: 24, period: hour } loaded_at_field: evt_block_time - name: ETHRegistrarController_1_evt_NameRenewed loaded_at_field: evt_block_time - name: ETHRegistrarController_2_evt_NameRenewed loaded_at_field: evt_block_time - name: ETHRegistrarController_3_evt_NameRenewed + freshness: + warn_after: { count: 12, period: hour } + error_after: { count: 24, period: hour } loaded_at_field: evt_block_time \ No newline at end of file diff --git a/spellbook/models/ens/ens_view_expirations.sql b/spellbook/models/ens/ens_view_expirations.sql index 1b9e01a0d97..d71632068db 100644 --- a/spellbook/models/ens/ens_view_expirations.sql +++ b/spellbook/models/ens/ens_view_expirations.sql @@ -8,15 +8,15 @@ SELECT count(*) AS count FROM ( SELECT - numeric2bytea(id) AS label, + conv((id),10,16) AS label, expires, evt_block_time FROM {{source('ethereumnameservice_ethereum', 'BaseRegistrarImplementation_evt_NameRegistered')}} UNION SELECT - numeric2bytea(id) AS label, + conv((id),10,16) AS label, expires, evt_block_time FROM {{source('ethereumnameservice_ethereum', 'BaseRegistrarImplementation_evt_NameRenewed')}} ) AS r -GROUP BY label; +GROUP BY label ; diff --git a/spellbook/models/ens/ens_view_registries.sql b/spellbook/models/ens/ens_view_registries.sql index 0729a5c9c6f..802d634782a 100644 --- a/spellbook/models/ens/ens_view_registries.sql +++ b/spellbook/models/ens/ens_view_registries.sql @@ -11,4 +11,4 @@ SELECT UNION SELECT * FROM {{source('ethereumnameservice_ethereum', 'ENSRegistryWithFallback_evt_NewOwner')}} ) r -GROUP BY node, label; +GROUP BY node, label ; diff --git a/spellbook/models/ens/ens_view_renewals.sql b/spellbook/models/ens/ens_view_renewals.sql index 0fe60deca1b..62ed24f7b36 100644 --- a/spellbook/models/ens/ens_view_renewals.sql +++ b/spellbook/models/ens/ens_view_renewals.sql @@ -6,4 +6,4 @@ SELECT * FROM {{source('ethereumnameservice_ethereum', 'ETHRegistrarController_2_evt_NameRenewed')}} UNION SELECT * -FROM {{source('ethereumnameservice_ethereum', 'ETHRegistrarController_3_evt_NameRenewed')}}; +FROM {{source('ethereumnameservice_ethereum', 'ETHRegistrarController_3_evt_NameRenewed')}} ; diff --git a/spellbook/seeds/ens/ens_ethereum_view_expirations_postgres.csv b/spellbook/seeds/ens/ens_view_expirations_postgres.csv similarity index 100% rename from spellbook/seeds/ens/ens_ethereum_view_expirations_postgres.csv rename to spellbook/seeds/ens/ens_view_expirations_postgres.csv diff --git a/spellbook/seeds/ens/ens_ethereum_view_registrations_postgres.csv b/spellbook/seeds/ens/ens_view_registrations_postgres.csv similarity index 100% rename from spellbook/seeds/ens/ens_ethereum_view_registrations_postgres.csv rename to spellbook/seeds/ens/ens_view_registrations_postgres.csv diff --git a/spellbook/seeds/ens/ens_ethreum_view_registries_postgres.csv b/spellbook/seeds/ens/ens_view_registries_postgres.csv similarity index 100% rename from spellbook/seeds/ens/ens_ethreum_view_registries_postgres.csv rename to spellbook/seeds/ens/ens_view_registries_postgres.csv diff --git a/spellbook/seeds/ens/ens_ethereum_view_renewals_postgres.csv b/spellbook/seeds/ens/ens_view_renewals_postgres.csv similarity index 100% rename from spellbook/seeds/ens/ens_ethereum_view_renewals_postgres.csv rename to spellbook/seeds/ens/ens_view_renewals_postgres.csv diff --git a/spellbook/tests/ens/ens_view_expiration_test.sql b/spellbook/tests/ens/ens_view_expirations_test.sql similarity index 87% rename from spellbook/tests/ens/ens_view_expiration_test.sql rename to spellbook/tests/ens/ens_view_expirations_test.sql index 5f0dc56a4d6..e1e49c16886 100644 --- a/spellbook/tests/ens/ens_view_expiration_test.sql +++ b/spellbook/tests/ens/ens_view_expirations_test.sql @@ -8,11 +8,11 @@ WITH unit_tests AS ( ELSE False END AS min_expiration_test FROM {{ ref('ens_view_expirations') }} AS ens_ve - JOIN {{ ref('ens_view_expirations_postgres') }} AS test_date + JOIN {{ ref('ens_view_expirations_postgres') }} AS test_data ON test_data.label = ens_ve.label ) SELECT COUNT(*) AS count_rows, COUNT(CASE WHEN min_expiration_test = FALSE THEN 1 ELSE NULL END)/COUNT(*) AS pct_mismatch FROM unit_tests -HAVING COUNT(CASE WHEN min_expiration_test = FALSE THEN 1 ELSE NULL END) > COUNT(*)*0.05; \ No newline at end of file +HAVING COUNT(CASE WHEN min_expiration_test = FALSE THEN 1 ELSE NULL END) > COUNT(*)*0.05 \ No newline at end of file diff --git a/spellbook/tests/ens/ens_view_registrations_test.sql b/spellbook/tests/ens/ens_view_registrations_test.sql index e64d65bd694..a4b36a56aee 100644 --- a/spellbook/tests/ens/ens_view_registrations_test.sql +++ b/spellbook/tests/ens/ens_view_registrations_test.sql @@ -3,16 +3,16 @@ -- Also manually check etherscan info for the first 5 rows WITH unit_tests AS ( SELECT - CASE WHEN test_data.label = ens_vr.label - AND test_data.evt_block_number = ens_vr.evt_block_number THEN TRUE + CASE WHEN test_data.label = ens_vr.label THEN TRUE ELSE False END AS evt_block_number_test FROM {{ ref('ens_view_registrations') }} AS ens_vr - JOIN {{ ref('ens_view_registrations_postgres') }} AS test_date - ON test_data.label = ens_vr.label + JOIN {{ ref('ens_view_registrations_postgres') }} AS test_data + ON test_data.evt_block_number = ens_vr.evt_block_number + AND test_data.evt_index = ens_vr.evt_index ) SELECT COUNT(*) AS count_rows, COUNT(CASE WHEN evt_block_number_test = FALSE THEN 1 ELSE NULL END)/COUNT(*) AS pct_mismatch FROM unit_tests -HAVING COUNT(CASE WHEN evt_block_number_test = FALSE THEN 1 ELSE NULL END) > COUNT(*)*0.05; \ No newline at end of file +HAVING COUNT(CASE WHEN evt_block_number_test = FALSE THEN 1 ELSE NULL END) > COUNT(*)*0.05 \ No newline at end of file diff --git a/spellbook/tests/ens/ens_view_registries_test.sql b/spellbook/tests/ens/ens_view_registries_test.sql index 0bdf4657b4e..ecb6ae8e280 100644 --- a/spellbook/tests/ens/ens_view_registries_test.sql +++ b/spellbook/tests/ens/ens_view_registries_test.sql @@ -3,16 +3,15 @@ -- Also manually check etherscan info for the first 5 rows WITH unit_tests AS ( SELECT - CASE WHEN test_data.label = ens_vr.label - AND test_data.min_evt_block_time = ens_vr.min_evt_block_time THEN True + CASE WHEN test_data.label = ens_vr.label THEN True ELSE False END AS min_evt_block_time_test FROM {{ ref('ens_view_registries') }} AS ens_vr - JOIN {{ ref('ens_view_registries_postgres') }} AS test_date - ON test_data.label = ens_vr.label + JOIN {{ ref('ens_view_registries_postgres') }} AS test_data + ON test_data.label = ens_vr.label and test_data.min_evt_block_time = ens_vr.min_evt_block_time ) SELECT COUNT(*) AS count_rows, COUNT(CASE WHEN min_evt_block_time_test = FALSE THEN 1 ELSE NULL END)/COUNT(*) AS pct_mismatch FROM unit_tests -HAVING COUNT(CASE WHEN min_evt_block_time_test = FALSE THEN 1 ELSE NULL END) > COUNT(*)*0.05; \ No newline at end of file +HAVING COUNT(CASE WHEN min_evt_block_time_test = FALSE THEN 1 ELSE NULL END) > COUNT(*)*0.05 \ No newline at end of file diff --git a/spellbook/tests/ens/ens_view_renewals_test.sql b/spellbook/tests/ens/ens_view_renewals_test.sql index b21d1fa0326..7027a066ae3 100644 --- a/spellbook/tests/ens/ens_view_renewals_test.sql +++ b/spellbook/tests/ens/ens_view_renewals_test.sql @@ -3,16 +3,16 @@ -- Also manually check etherscan info for the first 5 rows WITH unit_tests AS ( SELECT - CASE WHEN test_data.label = ens_vr.label - AND test_data.evt_block_number = ens_vr.evt_block_number THEN True + CASE WHEN test_data.label = ens_vr.label THEN True ELSE False END AS evt_block_number_test FROM {{ ref('ens_view_renewals') }} AS ens_vr - JOIN {{ ref('ens_view_renewals_postgres') }} AS test_date - ON test_data.label = ens_vr.label + JOIN {{ ref('ens_view_renewals_postgres') }} AS test_data + ON test_data.evt_block_number = ens_vr.evt_block_number + AND test_data.evt_index = ens_vr.evt_index ) SELECT COUNT(*) AS count_rows, COUNT(CASE WHEN evt_block_number_test = FALSE THEN 1 ELSE NULL END)/COUNT(*) AS pct_mismatch FROM unit_tests -HAVING COUNT(CASE WHEN evt_block_number_test = FALSE THEN 1 ELSE NULL END) > COUNT(*)*0.05; \ No newline at end of file +HAVING COUNT(CASE WHEN evt_block_number_test = FALSE THEN 1 ELSE NULL END) > COUNT(*)*0.05 \ No newline at end of file