From 903f168366e7cc1ad3614eb4ac3bfbb16981cd34 Mon Sep 17 00:00:00 2001 From: Carl Cervone <42869436+ccerv1@users.noreply.github.com> Date: Sun, 15 Sep 2024 16:39:41 -0400 Subject: [PATCH] feat(dbt): add release_published github event type (#2146) --- .../models/intermediate/events/int_events.sql | 22 +++++++++++++++++++ .../staging/github/stg_github__releases.sql | 15 +++++++++++++ .../staging/github/stg_github__schema.yml | 19 +++++++++++++++- 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 warehouse/dbt/models/staging/github/stg_github__releases.sql diff --git a/warehouse/dbt/models/intermediate/events/int_events.sql b/warehouse/dbt/models/intermediate/events/int_events.sql index aca3effe6..ae0fe84d5 100644 --- a/warehouse/dbt/models/intermediate/events/int_events.sql +++ b/warehouse/dbt/models/intermediate/events/int_events.sql @@ -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`, @@ -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 ) ) diff --git a/warehouse/dbt/models/staging/github/stg_github__releases.sql b/warehouse/dbt/models/staging/github/stg_github__releases.sql new file mode 100644 index 000000000..991408871 --- /dev/null +++ b/warehouse/dbt/models/staging/github/stg_github__releases.sql @@ -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 diff --git a/warehouse/dbt/models/staging/github/stg_github__schema.yml b/warehouse/dbt/models/staging/github/stg_github__schema.yml index 7291b955f..d7b6c6262 100644 --- a/warehouse/dbt/models/staging/github/stg_github__schema.yml +++ b/warehouse/dbt/models/staging/github/stg_github__schema.yml @@ -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 @@ -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" \ No newline at end of file