Skip to content

Commit

Permalink
add: rf4 onchain eligibility checker (#1623)
Browse files Browse the repository at this point in the history
* add: rf4 onchain eligibility checker

* revert incremental models not stashed

* fix: removing trailing comma
  • Loading branch information
ccerv1 authored Jun 12, 2024
1 parent 5ae1dba commit de0ca8d
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{
config(
materialized='table',
materialized='incremental',
partition_by={
"field": "txn_date",
"data_type": "timestamp",
Expand Down

0 comments on commit de0ca8d

Please sign in to comment.