-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create initial metric models for rf4 (#1406)
* fix: remove EOA requirement to user model * add: passport source file * add passport staging model * add: superchain core models * fix typo * fix: passport source * fix: trusted user model * add trusted transactions table * add: initial metrics and summary table * first batch of trusted user metrics * (bug) remove duplicate artifact types from OP contract invocation events * fix: lower case to/from_namespace for OP events * (bug) apply artifact_type deduping to other superchain contract events * fix: remove to/from_namespace from select in L2 contract events model * add: dau/mau models and rename other metrics tables * add: recurring users and onboarded users models
- Loading branch information
Showing
16 changed files
with
436 additions
and
49 deletions.
There are no files selected for viewing
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
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
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
9 changes: 9 additions & 0 deletions
9
warehouse/dbt/models/marts/superchain/metrics/rf4_gas_fees.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,9 @@ | ||
select | ||
project_id, | ||
'gas_fees' as metric, | ||
SUM(amount / 1e18) as amount | ||
from {{ ref('rf4_events_daily_to_project') }} | ||
where | ||
event_type = 'CONTRACT_INVOCATION_DAILY_L2_GAS_USED' | ||
group by | ||
project_id |
10 changes: 10 additions & 0 deletions
10
warehouse/dbt/models/marts/superchain/metrics/rf4_transactions.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,10 @@ | ||
select | ||
project_id, | ||
'transaction_count' as metric, | ||
SUM(amount) as amount | ||
from {{ ref('rf4_events_daily_to_project') }} | ||
where | ||
event_type = 'CONTRACT_INVOCATION_SUCCESS_DAILY_COUNT' | ||
and bucket_day >= '2023-10-01' | ||
group by | ||
project_id |
40 changes: 40 additions & 0 deletions
40
warehouse/dbt/models/marts/superchain/metrics/rf4_trusted_daily_active_users.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,40 @@ | ||
with txns as ( | ||
select | ||
project_id, | ||
trusted_user_id, | ||
bucket_day | ||
from {{ ref('rf4_events_daily_to_project') }} | ||
where | ||
event_type = 'CONTRACT_INVOCATION_SUCCESS_DAILY_COUNT' | ||
and bucket_day >= '2023-10-01' | ||
and trusted_user_id is not null | ||
), | ||
|
||
daus as ( | ||
select | ||
project_id, | ||
bucket_day, | ||
COUNT(distinct trusted_user_id) as trusted_users | ||
from txns | ||
group by | ||
project_id, | ||
bucket_day | ||
), | ||
|
||
total_days as ( | ||
select DATE_DIFF(max_day, min_day, day) + 1 as days | ||
from ( | ||
select | ||
MIN(bucket_day) as min_day, | ||
MAX(bucket_day) as max_day | ||
from txns | ||
) | ||
) | ||
|
||
select | ||
project_id, | ||
'trusted_daily_active_users' as metric, | ||
SUM(trusted_users) / (select days from total_days) as amount | ||
from daus | ||
group by | ||
project_id |
42 changes: 42 additions & 0 deletions
42
warehouse/dbt/models/marts/superchain/metrics/rf4_trusted_monthly_active_users.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,42 @@ | ||
with txns as ( | ||
select | ||
project_id, | ||
trusted_user_id, | ||
TIMESTAMP_TRUNC(bucket_day, month) as bucket_month | ||
from {{ ref('rf4_events_daily_to_project') }} | ||
where | ||
event_type = 'CONTRACT_INVOCATION_SUCCESS_DAILY_COUNT' | ||
and bucket_day >= '2023-10-01' | ||
and trusted_user_id is not null | ||
), | ||
|
||
maus as ( | ||
select | ||
project_id, | ||
bucket_month, | ||
COUNT(distinct trusted_user_id) as trusted_users | ||
from txns | ||
group by | ||
project_id, | ||
bucket_month | ||
), | ||
|
||
total_months as ( | ||
select | ||
{# TODO: double check this math #} | ||
(DATE_DIFF(max_month, min_month, day) + 30) / 30 as months | ||
from ( | ||
select | ||
MIN(bucket_month) as min_month, | ||
MAX(bucket_month) as max_month | ||
from txns | ||
) | ||
) | ||
|
||
select | ||
project_id, | ||
'trusted_monthly_active_users' as metric, | ||
SUM(trusted_users) / (select months from total_months) as amount | ||
from maus | ||
group by | ||
project_id |
35 changes: 35 additions & 0 deletions
35
warehouse/dbt/models/marts/superchain/metrics/rf4_trusted_recurring_users.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,35 @@ | ||
with txns as ( | ||
select | ||
project_id, | ||
trusted_user_id, | ||
bucket_day, | ||
TIMESTAMP_TRUNC(bucket_day, month) as bucket_month | ||
from {{ ref('rf4_events_daily_to_project') }} | ||
where | ||
event_type = 'CONTRACT_INVOCATION_SUCCESS_DAILY_COUNT' | ||
and bucket_day >= '2023-10-01' | ||
and trusted_user_id is not null | ||
), | ||
|
||
user_stats as ( | ||
select | ||
project_id, | ||
trusted_user_id, | ||
COUNT(distinct bucket_month) as months, | ||
MAX(bucket_day) as last_day | ||
from txns | ||
group by | ||
project_id, | ||
trusted_user_id | ||
) | ||
|
||
select | ||
project_id, | ||
'trusted_recurring_users' as metric, | ||
COUNT(distinct trusted_user_id) as amount | ||
from user_stats | ||
where | ||
months >= 3 | ||
and last_day >= '2024-04-01' | ||
group by | ||
project_id |
11 changes: 11 additions & 0 deletions
11
warehouse/dbt/models/marts/superchain/metrics/rf4_trusted_transactions.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,11 @@ | ||
select | ||
project_id, | ||
'trusted_transaction_count' as metric, | ||
SUM(amount) as amount | ||
from {{ ref('rf4_events_daily_to_project') }} | ||
where | ||
event_type = 'CONTRACT_INVOCATION_SUCCESS_DAILY_COUNT' | ||
and bucket_day >= '2023-10-01' | ||
and trusted_user_id is not null | ||
group by | ||
project_id |
Oops, something went wrong.