Skip to content

Commit

Permalink
Update ens_ethereum_sources.yml (#1254)
Browse files Browse the repository at this point in the history
Brief comments on the purpose of your changes:


*For Dune Engine V2*
I've checked that:

* [ ] I tested the query on dune.com after compiling the model with dbt compile (compiled queries are written to the target directory)
* [ ] I used "refs" to reference other models in this repo and "sources" to reference raw or decoded tables 
* [ ] if adding a new model, I added a test
* [ ] the filename is unique and ends with .sql
* [ ] each sql file is a select statement and has only one view, table or function defined  
* [ ] column names are `lowercase_snake_cased`

When you are ready for a review, tag duneanalytics/data-experience. We will re-open your forked pull request as an internal pull request. Then your spells will run in dbt and the logs will be avaiable in Github Actions DBT Slim CI. This job will only run the models and tests changed by your PR compared to the production project.
  • Loading branch information
soispoke authored Jul 6, 2022
1 parent ab80c50 commit b489db6
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 24 deletions.
20 changes: 18 additions & 2 deletions spellbook/models/ens/ens_ethereum_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions spellbook/models/ens/ens_view_expirations.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;
2 changes: 1 addition & 1 deletion spellbook/models/ens/ens_view_registries.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ SELECT
UNION
SELECT * FROM {{source('ethereumnameservice_ethereum', 'ENSRegistryWithFallback_evt_NewOwner')}}
) r
GROUP BY node, label;
GROUP BY node, label ;
2 changes: 1 addition & 1 deletion spellbook/models/ens/ens_view_renewals.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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')}} ;
Original file line number Diff line number Diff line change
Expand Up @@ -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;
HAVING COUNT(CASE WHEN min_expiration_test = FALSE THEN 1 ELSE NULL END) > COUNT(*)*0.05
10 changes: 5 additions & 5 deletions spellbook/tests/ens/ens_view_registrations_test.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
HAVING COUNT(CASE WHEN evt_block_number_test = FALSE THEN 1 ELSE NULL END) > COUNT(*)*0.05
9 changes: 4 additions & 5 deletions spellbook/tests/ens/ens_view_registries_test.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
HAVING COUNT(CASE WHEN min_evt_block_time_test = FALSE THEN 1 ELSE NULL END) > COUNT(*)*0.05
10 changes: 5 additions & 5 deletions spellbook/tests/ens/ens_view_renewals_test.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
HAVING COUNT(CASE WHEN evt_block_number_test = FALSE THEN 1 ELSE NULL END) > COUNT(*)*0.05

0 comments on commit b489db6

Please sign in to comment.