-
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.
dbt: onchain int models for more composable impact metrics (#1266)
* fix: new users in onchain metrics * refactor: int models * update onchain marts * update code metrics marts * add groupbys * fix: typo in contributors pm * fix: ambiguous column * remove typo * fix: code metrics
- Loading branch information
Showing
21 changed files
with
486 additions
and
245 deletions.
There are no files selected for viewing
File renamed without changes.
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
22 changes: 22 additions & 0 deletions
22
warehouse/dbt/models/intermediate/users/int_addresses_daily_activity.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,22 @@ | ||
{# | ||
Address stats by project and network | ||
#} | ||
|
||
SELECT | ||
e.project_id, | ||
e.from_namespace, | ||
e.from_id, | ||
e.bucket_day, | ||
e.amount, | ||
CASE | ||
WHEN e.bucket_day = a.date_first_txn THEN 'NEW' | ||
ELSE 'RETURNING' | ||
END AS address_type | ||
FROM {{ ref('int_user_events_daily_to_project') }} AS e | ||
LEFT JOIN {{ ref('int_addresses') }} AS a | ||
ON | ||
e.from_id = a.from_id | ||
AND e.from_namespace = a.network | ||
AND e.project_id = a.project_id | ||
WHERE | ||
e.event_type = 'CONTRACT_INVOCATION_DAILY_COUNT' |
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
32 changes: 32 additions & 0 deletions
32
warehouse/dbt/models/intermediate/users/int_user_events_daily_to_collection.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,32 @@ | ||
{# | ||
This model aggregates user events to collection level on | ||
a daily basis. It is used to calculate various | ||
user engagement metrics by project. | ||
#} | ||
|
||
SELECT | ||
from_id, | ||
from_namespace, | ||
collection_id, | ||
event_type, | ||
TIMESTAMP_TRUNC(time, DAY) AS bucket_day, | ||
SUM(amount) AS amount | ||
FROM {{ ref('int_events_to_collection') }} | ||
WHERE | ||
event_type IN ( | ||
'COMMIT_CODE', | ||
'PULL_REQUEST_OPENED', | ||
'PULL_REQUEST_REOPENED', | ||
'PULL_REQUEST_CLOSED', | ||
'PULL_REQUEST_MERGED', | ||
'ISSUE_CLOSED', | ||
'ISSUE_OPENED', | ||
'ISSUE_REOPENED', | ||
'CONTRACT_INVOCATION_DAILY_COUNT' | ||
) | ||
GROUP BY | ||
from_id, | ||
from_namespace, | ||
collection_id, | ||
event_type, | ||
TIMESTAMP_TRUNC(time, DAY) |
32 changes: 32 additions & 0 deletions
32
warehouse/dbt/models/intermediate/users/int_user_events_daily_to_project.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,32 @@ | ||
{# | ||
This model aggregates user events to project level on | ||
a daily basis. It is used to calculate various | ||
user engagement metrics by project. | ||
#} | ||
|
||
SELECT | ||
from_id, | ||
from_namespace, | ||
project_id, | ||
event_type, | ||
TIMESTAMP_TRUNC(time, DAY) AS bucket_day, | ||
SUM(amount) AS amount | ||
FROM {{ ref('int_events_to_project') }} | ||
WHERE | ||
event_type IN ( | ||
'COMMIT_CODE', | ||
'PULL_REQUEST_OPENED', | ||
'PULL_REQUEST_REOPENED', | ||
'PULL_REQUEST_CLOSED', | ||
'PULL_REQUEST_MERGED', | ||
'ISSUE_CLOSED', | ||
'ISSUE_OPENED', | ||
'ISSUE_REOPENED', | ||
'CONTRACT_INVOCATION_DAILY_COUNT' | ||
) | ||
GROUP BY | ||
from_id, | ||
from_namespace, | ||
project_id, | ||
event_type, | ||
TIMESTAMP_TRUNC(time, DAY) |
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
21 changes: 21 additions & 0 deletions
21
warehouse/dbt/models/intermediate/users/int_user_events_to_project_by_time_interval.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,21 @@ | ||
{# | ||
This model aggregates user events to project level by time interval. | ||
It is used to calculate various user engagement metrics by project. | ||
#} | ||
|
||
SELECT | ||
e.from_id, | ||
e.from_namespace, | ||
e.project_id, | ||
t.time_interval, | ||
e.event_type, | ||
SUM(e.amount) AS amount | ||
FROM {{ ref('int_user_events_daily_to_project') }} AS e | ||
CROSS JOIN {{ ref('int_time_intervals') }} AS t | ||
WHERE DATE(e.bucket_day) >= t.start_date | ||
GROUP BY | ||
e.from_id, | ||
e.project_id, | ||
e.from_namespace, | ||
t.time_interval, | ||
e.event_type |
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
Oops, something went wrong.