Skip to content

Commit

Permalink
feat: include dates for first/last events to repo from Github API in …
Browse files Browse the repository at this point in the history
…code metrics marts (#2346)

* chore: updating staging model

* chore: update staging schema

* feat(dbt): include first/last updates to repo

* feat(dbt): add first/last update to code metrics mart

* fix: trailing whitespace
  • Loading branch information
ccerv1 authored Nov 3, 2024
1 parent 038806c commit 3e4236c
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ repos as (
select
project_id,
artifact_source as event_source,
MIN(created_at) as first_created_at_date,
MAX(updated_at) as last_updated_at_date,
MIN(first_commit_time) as first_commit_date,
MAX(last_commit_time) as last_commit_date,
COUNT(distinct artifact_id) as repository_count,
Expand Down Expand Up @@ -172,6 +174,8 @@ select
project_metadata.project_name,
project_metadata.display_name,
project_metadata.event_source,
code_metrics.first_created_at_date,
code_metrics.last_updated_at_date,
code_metrics.first_commit_date,
code_metrics.last_commit_date,
code_metrics.repository_count,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ with repo_artifact as (
license_spdx_id,
language,
watcher_count,
created_at,
updated_at,
CAST(id as STRING) as artifact_source_id,
LOWER(owner) as artifact_namespace,
LOWER(name) as artifact_name
Expand All @@ -29,7 +31,9 @@ repo_snapshot as (
is_fork,
fork_count,
star_count,
watcher_count
watcher_count,
created_at,
updated_at
from repo_artifact as a
),

Expand Down Expand Up @@ -75,6 +79,8 @@ select distinct
repo_snapshot.watcher_count,
repo_snapshot.language,
repo_snapshot.license_spdx_id,
repo_snapshot.created_at,
repo_snapshot.updated_at,
repo_stats.first_commit_time,
repo_stats.last_commit_time,
repo_stats.days_with_commits_count,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ select
display_name,
event_source,
repository_count,
first_created_at_date,
last_updated_at_date,
first_commit_date,
last_commit_date,
star_count,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ with ranked_repositories as (
license_name,
license_spdx_id,
language,
ingestion_time,
created_at,
updated_at,
ingestion_time,
ROW_NUMBER()
over (partition by node_id order by ingestion_time desc, id asc)
as row_num
Expand All @@ -41,8 +41,8 @@ select
license_name,
license_spdx_id,
language,
ingestion_time,
created_at,
updated_at
updated_at,
ingestion_time
from ranked_repositories
where row_num = 1
20 changes: 19 additions & 1 deletion warehouse/dbt/models/staging/oss-directory/stg_ossd__schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,24 @@ models:
- &is_fork
name: is_fork
description: "is this repo a fork?"
- &license_name
name: license_name
description: "license name"
- &license_spdx_id
name: license_spdx_id
description: "license spdx id"
- &language
name: language
description: "programming language used in the repository"
- &created_at
name: created_at
description: "repository creation timestamp"
- &updated_at
name: updated_at
description: "repository last update timestamp"
- &ingestion_time
name: ingestion_time
description: "timestamp when the data was ingested"
- name: stg_ossd__missing_sbom
meta:
#...
Expand All @@ -148,4 +166,4 @@ models:
description: "artifact source, currently only GITHUB"
- *artifact_url
- name: snapshot_at
description: "snapshot time"
description: "snapshot time"

0 comments on commit 3e4236c

Please sign in to comment.