Skip to content

Commit

Permalink
feat: more metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
louisjoecodes committed Feb 13, 2024
1 parent 8c05f81 commit 237ffab
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 4 deletions.
15 changes: 15 additions & 0 deletions models/intermediate/pull_requests_time_to_close.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
SELECT
id,
state,
title,
created_at,
updated_at,
closed_at,
merged_at,
repository,
author,
TIMESTAMP_DIFF(closed_at, created_at, HOUR) AS time_to_close_hours
FROM
q.stg_pull_requests
WHERE
closed_at IS NOT NULL
25 changes: 25 additions & 0 deletions models/intermediate/schema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
models:
- name: pull_requests_time_to_close
columns:
- name: id
description: The pull request identifier.
- name: state
description: The pull request state, either closed or open.
- name: title
description: The pull request title.
- name: created_at
description: The time the pull request was created.
- name: updated_at
description: The time the pull request was last updated.
- name: closed_at
description: The time the pull request was closed.
tests:
- type: not_null
- name: merged_at
description: The time the pull request was merged.
- name: repository
description: The pull request repository.
- name: author
description: The author of the pull request.
- name: time_to_close_hours
description: The time taken to close a pull request.
13 changes: 13 additions & 0 deletions models/metrics/time_to_close.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
SELECT
repository,
FORMAT_TIMESTAMP('%Y-%U', created_at) AS year_week,
ROUND(AVG(time_to_close_hours)) AS avg_time_to_close,
ROUND(MIN(time_to_close_hours)) AS min_time_to_close,
ROUND(MAX(time_to_close_hours)) AS max_time_to_close,
COUNT(id) AS total_prs_closed
FROM
q.pull_requests_time_to_close
GROUP BY
repository, year_week
ORDER BY
repository, year_week
68 changes: 64 additions & 4 deletions models/staging/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,24 @@ sources:
- name: state
- name: updated_at
- name: url
- name: raw_commits
path: quary-analytics.airbyte_github.commits
columns:
- name: _airbyte_extracted_at
- name: _airbyte_meta
- name: _airbyte_raw_id
- name: author
- name: branch
- name: comments_url
- name: commit
- name: committer
- name: created_at
- name: html_url
- name: node_id
- name: parents
- name: repository
- name: sha
- name: url
models:
- name: stg_workflow_runs
description: Staging table defining the GitHub Actions workflow runs, detailing each run's initiation, completion, status, and outcome within the organisation's CI/CD process.
Expand All @@ -447,10 +465,6 @@ models:
description: The current status for the workflow run.
- name: conclusion
description: The outcome of the workflow run.
tests:
- type: accepted_values
info:
values: success, cancelled, startup_failure, failure
- name: event
description: The type of event that triggered the workflow run.
- name: head_branch
Expand All @@ -465,3 +479,49 @@ models:
description: The unique identifier (SHA) of the most recent commit in the branch at the time the workflow run was triggered.
- name: head_commit_timestamp
description: ": The timestamp of the most recent commit that triggered the workflow run, providing a precise moment when the code changes were made. "
- name: stg_pull_requests
description: Raw Pull Requests coming from Github.
columns:
- name: id
description: The pull request identifier.
tests:
- type: unique
- type: not_null
- name: state
description: The pull request state, either closed or open.
tests:
- type: accepted_values
info:
values: closed,open
- name: title
description: The pull request title.
- name: created_at
description: The time the pull request was created.
- name: updated_at
description: The time the pull request was last updated.
- name: closed_at
description: The time the pull request was closed.
- name: merged_at
description: The time the pull request was merged.
- name: repository
description: The pull request repository.
- name: author
description: The author of the pull request.
- name: stg_commits
description: Replace this with your description for commits
columns:
- name: _airbyte_extracted_at
- name: _airbyte_meta
- name: _airbyte_raw_id
- name: author
- name: branch
- name: comments_url
- name: commit
- name: committer
- name: created_at
- name: html_url
- name: node_id
- name: parents
- name: repository
- name: sha
- name: url
17 changes: 17 additions & 0 deletions models/staging/stg_commits.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
SELECT
_airbyte_extracted_at AS _airbyte_extracted_at,
_airbyte_meta AS _airbyte_meta,
_airbyte_raw_id AS _airbyte_raw_id,
author AS author,
branch AS branch,
comments_url AS comments_url,
commit AS commit,
committer AS committer,
created_at AS created_at,
html_url AS html_url,
node_id AS node_id,
parents AS parents,
repository AS repository,
sha AS sha,
url AS url
FROM q.raw_commits
13 changes: 13 additions & 0 deletions models/staging/stg_pull_requests.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
SELECT
id,
state,
title,
created_at,
updated_at,
closed_at,
merged_at,
repository,
JSON_VALUE(user, '$.login') AS author,

FROM
q.raw_pull_requests
1 change: 1 addition & 0 deletions models/staging/stg_workflow_runs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ SELECT
workflow_id,
JSON_VALUE(head_commit, '$.id') AS head_commit_id,
JSON_VALUE(head_commit, '$.timestamp') AS head_commit_timestamp,

FROM
q.raw_workflow_runs

0 comments on commit 237ffab

Please sign in to comment.