Skip to content

Commit

Permalink
dbt: fix to RF4 date windows and join on app id (#1661)
Browse files Browse the repository at this point in the history
* refactor: explicit event window for daily events

* fix: date windows and join on agora app ids

* fix: remove null app ids
  • Loading branch information
ccerv1 authored Jun 17, 2024
1 parent c2f7f8a commit 4abf1b1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ select
from {{ ref('rf4_events_daily_to_project') }}
where
event_type = 'CONTRACT_INVOCATION_DAILY_L2_GAS_USED'
and bucket_day >= '2023-10-01'
group by
project_id
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,21 @@ with events as (
'MODE',
'ZORA'
)
and time < '2024-05-23'
and time < '2024-06-01'
group by
project_id,
from_artifact_id,
to_artifact_id,
event_source,
event_type,
TIMESTAMP_TRUNC(time, day)
),

artifacts as (
select distinct
artifact_id,
artifact_name
from {{ ref('artifacts_v1') }}
)

select
Expand All @@ -45,13 +52,12 @@ select
then rf4_trusted_users.address
end as trusted_user_id
from events
left join {{ ref('int_artifact_types') }} as to_artifacts
left join artifacts as to_artifacts
on events.to_artifact_id = to_artifacts.artifact_id
left join {{ ref('artifacts_v1') }} as from_artifacts
left join artifacts as from_artifacts
on events.from_artifact_id = from_artifacts.artifact_id
left join {{ ref('projects_v1') }}
on events.project_id = projects_v1.project_id
left join {{ ref('rf4_trusted_users') }}
on from_artifacts.artifact_name = rf4_trusted_users.address
where
to_artifacts.artifact_type = 'CONTRACT'
where events.amount > 0
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ pivot_metrics as (
)

select
pivot_metrics.project_id,
projects_v1.project_name,
agora_rf4_to_ossd.application_id,
agora_rf4_to_ossd.oso_project_name,
pivot_metrics.check_oss_requirements,
pivot_metrics.gas_fees,
pivot_metrics.transaction_count,
Expand All @@ -101,3 +101,6 @@ select
from pivot_metrics
left join {{ ref('projects_v1') }}
on pivot_metrics.project_id = projects_v1.project_id
left join {{ source("static_data_sources", "agora_rf4_to_ossd") }}
on projects_v1.project_name = agora_rf4_to_ossd.oso_project_name
where agora_rf4_to_ossd.application_id is not null

0 comments on commit 4abf1b1

Please sign in to comment.