-
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.
* add: `active_developers` sqlmesh metric * add: `closed_issues` sqlmesh metric * add: `contributors` sqlmesh metric * add: `first_commit_date` sqlmesh metric * add: `last_commit` sqlmesh metric * add: `new_contributors` sqlmesh metric * add: `repositories` sqlmesh metric * add: developer_states sqlmesh metric models * fix: remove `duplicated` model * add: point in time and interval `models` * Adds dbt point in time metrics from source data * Disable first and last commits for now * Add point_in_time_v0 * fix * more fixes and tests --------- Co-authored-by: Reuven V. Gonzales <[email protected]>
- Loading branch information
Showing
13 changed files
with
297 additions
and
15 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
warehouse/dbt/models/intermediate/point_in_time/int_point_in_time_from_sources.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 @@ | ||
{# | ||
Point in time metrics that are taken from raw sources. This does not do any | ||
point in time aggregations for running sums/averages. | ||
|
||
Not all collected data has historical state information but some things do. This | ||
is to include those for greater accuracy when rendering metrics | ||
|
||
This is particularly useful for: | ||
* Star Count (using STARRED events doesn't capture accurate star counts) | ||
* Watcher Count | ||
* Repository Count (This is an aggregated metric for a project/collection) | ||
Other things in the future will likely be useful here but for now this is just | ||
for repository related metrics that aren't timeseries by nature. | ||
#} | ||
select | ||
`time`, | ||
artifact_source, | ||
{{ oso_id("artifact_source", "artifact_source_id") }} as artifact_id, | ||
metric, | ||
amount | ||
from {{ ref("stg_ossd__repository_point_in_time") }} |
14 changes: 14 additions & 0 deletions
14
warehouse/dbt/models/marts/point_in_time/point_in_time_v0.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,14 @@ | ||
{{ | ||
config(meta = { | ||
'sync_to_db': True, | ||
'order_by': [ 'artifact_source', 'metric', 'artifact_id', 'time' ] | ||
}) | ||
}} | ||
|
||
select | ||
time, | ||
artifact_source, | ||
artifact_id, | ||
metric, | ||
amount | ||
from {{ ref("int_point_in_time_from_sources") }} |
17 changes: 17 additions & 0 deletions
17
warehouse/dbt/models/staging/oss-directory/stg_ossd__repository_point_in_time.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,17 @@ | ||
{# | ||
Point in time view for repository data. | ||
#} | ||
select | ||
repo.ingestion_time as `time`, | ||
"GITHUB" as artifact_source, | ||
"REPOSITORY" as artifact_type, | ||
repo.owner as artifact_namespace, | ||
repo.name as artifact_name, | ||
repo.id as artifact_source_id, | ||
unpivoted.metric as metric, | ||
unpivoted.amount as amount | ||
from {{ oso_source('ossd', 'repositories') }} as repo, unnest([ | ||
struct("fork_count" as metric, fork_count as amount), | ||
struct("star_count" as metric, star_count as amount), | ||
struct("watcher_count" as metric, watcher_count as amount) | ||
]) as unpivoted |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
select @metrics_sample_date(events.bucket_day) as metrics_sample_date, | ||
events.event_source, | ||
events.to_artifact_id as to_artifact_id, | ||
'' as from_artifact_id, | ||
@metric_name() as metric, | ||
COUNT(distinct events.from_artifact_id) as amount | ||
from metrics.events_daily_to_artifact as events | ||
where events.event_type = 'COMMIT_CODE' | ||
and events.bucket_day BETWEEN @metrics_start('DATE') AND @metrics_end('DATE') | ||
group by 1, | ||
metric, | ||
from_artifact_id, | ||
to_artifact_id, | ||
event_source |
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,19 @@ | ||
select @metrics_sample_date(events.bucket_day) as metrics_sample_date, | ||
events.event_source, | ||
events.to_artifact_id as to_artifact_id, | ||
'' as from_artifact_id, | ||
@metric_name() as metric, | ||
COUNT(distinct events.from_artifact_id) as amount | ||
from metrics.events_daily_to_artifact as events | ||
where events.event_type in ( | ||
'COMMIT_CODE', | ||
'ISSUE_OPENED', | ||
'PULL_REQUEST_OPENED', | ||
'PULL_REQUEST_MERGED' | ||
) | ||
and events.bucket_day BETWEEN @metrics_start('DATE') AND @metrics_end('DATE') | ||
group by 1, | ||
metric, | ||
from_artifact_id, | ||
to_artifact_id, | ||
event_source |
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,17 @@ | ||
-- TODO (@ravenac95) keeping this for now, might prove useful, but we likely need | ||
-- a different kind of model for first commit data | ||
select @metrics_sample_date(events.bucket_day) as metrics_sample_date, | ||
events.event_source, | ||
events.to_artifact_id as to_artifact_id, | ||
'' as from_artifact_id, | ||
@metric_name() as metric, | ||
1 as amount, | ||
MIN(events.bucket_day) as first_commit_date | ||
from metrics.events_daily_to_artifact as events | ||
where events.event_type = 'COMMIT_CODE' | ||
and events.bucket_day BETWEEN @metrics_start('DATE') AND @metrics_end('DATE') | ||
group by 1, | ||
metric, | ||
from_artifact_id, | ||
to_artifact_id, | ||
event_source |
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,17 @@ | ||
-- TODO (@ravenac95) keeping this for now, might prove useful, but we likely need | ||
-- a different kind of model for last commit data | ||
select @metrics_sample_date(events.bucket_day) as metrics_sample_date, | ||
events.event_source, | ||
events.to_artifact_id as to_artifact_id, | ||
'' as from_artifact_id, | ||
@metric_name() as metric, | ||
1 as amount, | ||
MAX(events.bucket_day) as last_commit_date | ||
from metrics.events_daily_to_artifact as events | ||
where events.event_type = 'COMMIT_CODE' | ||
and events.bucket_day BETWEEN @metrics_start('DATE') AND @metrics_end('DATE') | ||
group by 1, | ||
metric, | ||
from_artifact_id, | ||
to_artifact_id, | ||
event_source |
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,25 @@ | ||
select @metrics_sample_date(events.bucket_day) as metrics_sample_date, | ||
events.event_source, | ||
events.to_artifact_id as to_artifact_id, | ||
'' as from_artifact_id, | ||
@metric_name() as metric, | ||
COUNT(distinct events.to_artifact_id) as amount | ||
from metrics.events_daily_to_artifact as events | ||
where events.event_type in ( | ||
'ISSUE_OPENED', | ||
'STARRED', | ||
'PULL_REQUEST_OPENED', | ||
'FORKED', | ||
'PULL_REQUEST_REOPENED', | ||
'PULL_REQUEST_CLOSED', | ||
'COMMIT_CODE', | ||
'ISSUE_REOPENED', | ||
'PULL_REQUEST_MERGED', | ||
'ISSUE_CLOSED', | ||
) | ||
and events.bucket_day BETWEEN @metrics_start('DATE') AND @metrics_end('DATE') | ||
group by 1, | ||
metric, | ||
from_artifact_id, | ||
to_artifact_id, | ||
event_source |
33 changes: 33 additions & 0 deletions
33
warehouse/metrics_mesh/tests/test_change_in_developers_over_window.yml
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,33 @@ | ||
test_change_in_30_day_developer_activity_to_artifact_over_2_period_window_full_time_devs: | ||
# Tests rolling count of active days when the user is active 4 of the 5 days | ||
# in the test interval | ||
gateway: local | ||
model: metrics.change_in_30_day_developer_activity_to_artifact_over_2_period_window | ||
vars: | ||
start: 2024-01-31 | ||
end: 2024-01-31 | ||
inputs: | ||
metrics.developer_classifications_to_artifact_over_30_day_window: | ||
rows: | ||
- to_artifact_id: repo_0 | ||
from_artifact_id: null | ||
event_source: SOURCE_PROVIDER | ||
metrics_sample_date: 2024-01-01 | ||
metric: full_time_developers_over_30_day_window | ||
amount: 30 | ||
- to_artifact_id: repo_0 | ||
from_artifact_id: null | ||
event_source: SOURCE_PROVIDER | ||
metrics_sample_date: 2024-01-31 | ||
metric: full_time_developers_over_30_day_window | ||
amount: 10 | ||
outputs: | ||
partial: true | ||
query: | ||
partial: true | ||
rows: | ||
- metrics_sample_date: 2024-01-31 | ||
to_artifact_id: repo_0 | ||
from_artifact_id: "" | ||
amount: -20 | ||
|
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
39 changes: 39 additions & 0 deletions
39
warehouse/metrics_mesh/tests/test_developer_classification_over_window.yml
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,39 @@ | ||
test_developer_classifications_to_artifact_over_30_day_window_full_time_devs: | ||
# Tests rolling count of active days when the user is active 4 of the 5 days | ||
# in the test interval | ||
gateway: local | ||
model: metrics.developer_classifications_to_artifact_over_30_day_window | ||
vars: | ||
start: 2024-01-01 | ||
end: 2024-01-01 | ||
inputs: | ||
metrics.developer_active_days_to_artifact_over_30_day_window: | ||
rows: | ||
- to_artifact_id: repo_0 | ||
from_artifact_id: dev_0 | ||
event_source: SOURCE_PROVIDER | ||
metrics_sample_date: 2024-01-01 | ||
metric: developer_active_days | ||
amount: 30 | ||
- to_artifact_id: repo_0 | ||
from_artifact_id: dev_1 | ||
event_source: SOURCE_PROVIDER | ||
metrics_sample_date: 2024-01-01 | ||
metric: developer_active_days | ||
amount: 30 | ||
outputs: | ||
partial: true | ||
query: | ||
partial: true | ||
rows: | ||
- metrics_sample_date: 2024-01-01 | ||
to_artifact_id: repo_0 | ||
from_artifact_id: "" | ||
metric: full_time_developers_over_30_day_window | ||
amount: 2 | ||
- metrics_sample_date: 2024-01-01 | ||
to_artifact_id: repo_0 | ||
from_artifact_id: "" | ||
metric: active_developers_over_30_day_window | ||
amount: 2 | ||
|
Oops, something went wrong.