-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add: rf4 onchain eligibility checker (#1623)
* add: rf4 onchain eligibility checker * revert incremental models not stashed * fix: removing trailing comma
- Loading branch information
Showing
2 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
warehouse/dbt/models/marts/superchain/verification/rf4_onchain_eligibility_checks.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
with projects as ( | ||
select | ||
app.application_id, | ||
app.project_name, | ||
ossd.oso_project_name | ||
from {{ source('static_data_sources', 'agora_rf4_applications') }} as app | ||
left join {{ source('static_data_sources', 'agora_rf4_to_ossd') }} as ossd | ||
on app.application_id = ossd.application_id | ||
), | ||
|
||
contracts as ( | ||
select | ||
application_id, | ||
count(distinct contract_address) as count_linked_addresses | ||
from {{ ref('rf4_contracts_by_app') }} | ||
group by application_id | ||
), | ||
|
||
txns as ( | ||
select | ||
application_id, | ||
txn_date, | ||
from_address, | ||
to_address, | ||
(txn_date > '2023-12-30' and txn_date < '2024-05-02') as txn_in_tight_window | ||
from {{ ref('rf4_transactions_by_app') }} | ||
) | ||
|
||
select | ||
projects.application_id, | ||
projects.project_name, | ||
projects.oso_project_name, | ||
contracts.count_linked_addresses, | ||
min(txns.txn_date) as first_transaction, | ||
count( | ||
distinct | ||
case when txns.txn_in_tight_window is true then txns.txn_date end | ||
) as num_active_days, | ||
count( | ||
distinct | ||
case when txns.txn_in_tight_window is true then txns.from_address end | ||
) as num_unique_addresses_in_tight_window, | ||
count(distinct txns.from_address) as num_unique_addresses_in_wide_window | ||
from projects | ||
left join contracts on projects.application_id = contracts.application_id | ||
left join txns on projects.application_id = txns.application_id | ||
group by | ||
projects.application_id, | ||
projects.project_name, | ||
projects.oso_project_name, | ||
contracts.count_linked_addresses | ||
order by | ||
projects.oso_project_name |
2 changes: 1 addition & 1 deletion
2
warehouse/dbt/models/marts/superchain/verification/rf4_transactions_window.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters