Skip to content

Commit

Permalink
feat(dbt): add release_published github event type (#2146)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccerv1 authored Sep 15, 2024
1 parent 9bc9c3c commit 903f168
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
22 changes: 22 additions & 0 deletions warehouse/dbt/models/intermediate/events/int_events.sql
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,26 @@ with github_commits as (
from {{ ref('stg_github__distinct_commits_resolved_mergebot') }}
),

github_releases as (
select -- noqa: ST06
created_at as `time`,
type as event_type,
CAST(id as STRING) as event_source_id,
"GITHUB" as event_source,
SPLIT(REPLACE(repository_name, "@", ""), "/")[SAFE_OFFSET(1)]
as to_name,
SPLIT(REPLACE(repository_name, "@", ""), "/")[SAFE_OFFSET(0)]
as to_namespace,
"REPOSITORY" as to_type,
CAST(repository_id as STRING) as to_artifact_source_id,
actor_login as from_name,
actor_login as from_namespace,
"GIT_USER" as from_type,
CAST(actor_id as STRING) as from_artifact_source_id,
CAST(1 as FLOAT64) as amount
from {{ ref('stg_github__releases') }}
),

github_issues as (
select -- noqa: ST06
created_at as `time`,
Expand Down Expand Up @@ -199,6 +219,8 @@ all_events as (
union all
select * from github_pull_request_merge_events
union all
select * from github_releases
union all
select * from github_stars_and_forks
)
)
Expand Down
15 changes: 15 additions & 0 deletions warehouse/dbt/models/staging/github/stg_github__releases.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
with release_events as (
select *
from {{ ref('stg_github__events') }} as ghe
where ghe.type = "ReleaseEvent"
)

select
id as id,
created_at as created_at,
repo.id as repository_id,
repo.name as repository_name,
actor.id as actor_id,
actor.login as actor_login,
"RELEASE_PUBLISHED" as `type`
from release_events
19 changes: 18 additions & 1 deletion warehouse/dbt/models/staging/github/stg_github__schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ models:
contributors: oso-team, tomfutago
config:
tags: ['staging', 'github', 'events', 'stars', 'forks']
description: "GitHub starts and forks"
description: "GitHub stars and forks"
columns:
- *id
- *created_at
Expand Down Expand Up @@ -224,3 +224,20 @@ models:
- *author_name
- *is_distinct
- *api_url

- name: stg_github__releases
meta:
#...
contributors: oso-team
config:
tags: ['staging', 'github', 'events', 'releases']
description: "GitHub releases"
columns:
- *id
- *created_at
- *repository_id
- *repository_name
- *actor_id
- *actor_login
- name: type
description: "release publishedevent type"

0 comments on commit 903f168

Please sign in to comment.