Repository navigation
feature/build-issue-label-history-model #85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
365e5e1
01646a3
e4d56bd
5e3b235
f9d313a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| version: 1.5.0 | ||
| pr_number: 85 | ||
| schema_data_changes: | ||
| entries: | ||
| - models: | ||
| - '[github__issue_label_history](https://fivetran.github.io/dbt_github/#!/model/model.github.github__issue_label_history)' | ||
| change_type: New model | ||
| notes: One row per period a label is applied to an issue or pull request, with | ||
| consecutive duplicate events collapsed. See the [DECISIONLOG](https://github.com/fivetran/dbt_github/blob/main/DECISIONLOG.md) | ||
| for details. Requires the `ISSUE_LABEL_HISTORY` and `LABEL` source tables. See | ||
| the [README](https://github.com/fivetran/dbt_github/#disable-models-for-non-existent-sources) | ||
| for details. | ||
| - models: | ||
| - '[stg_github__issue_label_history](https://fivetran.github.io/dbt_github/#!/model/model.github.stg_github__issue_label_history)' | ||
| - '[stg_github__issue_label_history_tmp](https://fivetran.github.io/dbt_github/#!/model/model.github.stg_github__issue_label_history_tmp)' | ||
| change_type: New staging and tmp models | ||
| notes: Stages the `ISSUE_LABEL_HISTORY` source table. | ||
| new_features: | ||
| - description: Adds the `github__using_issue_label_history` variable, which is dynamically | ||
| configured in Quickstart and defaults to `true` for self-managed dbt projects. | ||
| Set to `false` to disable if you don't sync the `ISSUE_LABEL_HISTORY` table. | ||
| date: '2026-11-04' | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| ## Decision Log | ||
|
|
||
| ### Building label intervals in `github__issue_label_history` | ||
| The `ISSUE_LABEL_HISTORY` source table records one event each time a label is added to or removed from an issue or pull request. The `github__issue_label_history` model turns these events into one row for each period a label is applied. We made the following decisions when building those periods: | ||
|
|
||
| - **Consecutive duplicate events are collapsed.** The source can record the same action more than once in a row. For example, a label is added twice with no removal in between. We keep only the first event in each run of duplicates. A repeated add does not start a new period, and a repeated removal does not end one. | ||
|
|
||
| - **Removals with no earlier add are dropped.** If the first event for an issue and label is a removal, the label was applied before the history starts. We drop that removal because the start of its period is unknown. | ||
|
|
||
| - **Events with a null `label_id` are excluded.** The source can record an event with only the label name and no `label_id`. Including them would add a second, merged set of periods with no label ID, so we exclude them. | ||
|
|
||
| - **Adds sort before removals on the same timestamp.** When an add and a removal share the same `updated_at` value, we order the add first. This produces a zero-length period instead of an orphan removal followed by an open period. | ||
|
|
||
| Each period starts at `valid_from`, the time of the add. It ends at `valid_until`, the time of the next removal. If the label is still applied, `valid_until` is `null` and `is_currently_applied` is `true`. `label_application_number` counts how many times the label has been applied to the issue, starting at 1. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ This dbt package transforms data from Fivetran's GitHub connector into analytics | |
|
|
||
| ## Resources | ||
|
|
||
| - Number of materialized models¹: 34 | ||
| - Number of materialized models¹: 37 | ||
| - Connector documentation | ||
| - [GitHub connector documentation](https://fivetran.com/docs/connectors/applications/github) | ||
| - [GitHub ERD](https://fivetran.com/docs/connectors/applications/github#schemainformation) | ||
|
|
@@ -39,6 +39,7 @@ By default, this package materializes the following final tables: | |
| | [github__weekly_metrics](https://fivetran.github.io/dbt_github/#!/model/model.github.github__weekly_metrics) | Aggregates weekly repository activity to analyze sprint-level productivity, track week-over-week trends, and understand development patterns at the weekly cadence. <br></br>**Example Analytics Questions:**<ul><li>What is the weekly throughput of pull requests and issues by repository?</li><li>How do weekly development metrics trend over time?</li><li>Which weeks show the highest productivity in terms of PRs merged and issues resolved?</li></ul>| | ||
| | [github__monthly_metrics](https://fivetran.github.io/dbt_github/#!/model/model.github.github__monthly_metrics) | Summarizes monthly repository activity to track long-term development trends, measure team productivity over time, and identify seasonal patterns in contribution activity. <br></br>**Example Analytics Questions:**<ul><li>How do monthly pull request and issue volumes trend across repositories?</li><li>What is the month-over-month growth in development activity and code contributions?</li><li>Which months show the highest productivity and how does this align with roadmap milestones?</li></ul>| | ||
| | [github__quarterly_metrics](https://fivetran.github.io/dbt_github/#!/model/model.github.github__quarterly_metrics) | Provides quarterly repository performance metrics to support strategic planning, measure progress against OKRs, and understand high-level development trends by quarter. <br></br>**Example Analytics Questions:**<ul><li>What is the quarterly velocity of feature development and issue resolution by repository?</li><li>How do quarterly metrics align with product roadmap goals and release cycles?</li><li>Which quarters show the strongest team performance and code contribution activity?</li></ul>| | ||
| | [github__issue_label_history](https://fivetran.github.io/dbt_github/#!/model/model.github.github__issue_label_history) | Tracks each period a label is applied to an issue or pull request, including when the label was added and removed and who added and removed it. <br></br>**Example Analytics Questions:**<ul><li>How long do issues typically keep a given label, such as `needs triage` or `blocked`?</li><li>How often is a label removed and re-applied to the same issue?</li><li>Which contributors apply and remove labels most often?</li></ul>| | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you update the model count in the README?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, interesting...that wasn't caught by the data model builder. Will open a PR for that.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated |
||
|
|
||
| ¹ Each Quickstart transformation job run materializes these models if all components of this data model are enabled. This count includes all staging, intermediate, and final models materialized as `view`, `table`, or `incremental`. | ||
|
|
||
|
|
@@ -65,7 +66,7 @@ Include the following github package version in your `packages.yml` file. | |
| ```yaml | ||
| packages: | ||
| - package: fivetran/github | ||
| version: [">=1.4.0", "<1.5.0"] # we recommend using ranges to capture non-breaking changes automatically | ||
| version: [">=1.5.0", "<1.6.0"] # we recommend using ranges to capture non-breaking changes automatically | ||
| ``` | ||
|
|
||
| > All required sources and staging models are now bundled into this transformation package. Do not include `fivetran/github_source` in your `packages.yml` since this package has been deprecated. | ||
|
|
@@ -115,14 +116,15 @@ If you use [Fivetran Transformations for dbt Core™](https://fivetran.com/docs/ | |
| ### Disable models for non-existent sources | ||
| Your GitHub connection might not sync every table that this package expects. If your syncs exclude certain tables, it is because you either don't use that functionality in GitHub or have actively excluded some tables from your syncs. | ||
|
|
||
| If you do not have the `TEAM`, `REPO_TEAM`, `ISSUE_ASSIGNEE`, `ISSUE_LABEL`, `LABEL`, or `REQUESTED_REVIEWER_HISTORY` tables synced and are not running the package via Fivetran Quickstart, add the following variables to your `dbt_project.yml` file: | ||
| If you do not have the `TEAM`, `REPO_TEAM`, `ISSUE_ASSIGNEE`, `ISSUE_LABEL`, `ISSUE_LABEL_HISTORY`, `LABEL`, or `REQUESTED_REVIEWER_HISTORY` tables synced and are not running the package via Fivetran Quickstart, add the following variables to your `dbt_project.yml` file: | ||
|
|
||
| ```yml | ||
| vars: | ||
| github__using_repo_team: false # by default this is assumed to be true. Set to false if missing TEAM or REPO_TEAM | ||
| github__using_issue_assignee: false # by default this is assumed to be true | ||
| github__using_issue_label: false # by default this is assumed to be true | ||
| github__using_label: false # by default this is assumed to be true | ||
| github__using_issue_label_history: false # by default this is assumed to be true | ||
| github__using_label: false # by default this is assumed to be true. Setting this to false also disables github__issue_label_history | ||
| github__using_requested_reviewer_history: false # by default this is assumed to be true | ||
| ``` | ||
|
|
||
|
|
||
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| issue_id,label_id,updated_at,labeled,actor_id,_fivetran_synced | ||
| 735542695,2856837944,2020-01-10 09:00:00,TRUE,20294432,2020-03-01 00:00:00 | ||
| 735542695,2856837944,2020-01-10 09:05:00,TRUE,10001014,2020-03-01 00:00:00 | ||
| 735542695,2856837944,2020-01-15 14:30:00,FALSE,10001014,2020-03-01 00:00:00 | ||
| 735542695,2856837944,2020-02-01 11:00:00,TRUE,20294432,2020-03-01 00:00:00 | ||
| 735542695,2022377955,2020-01-05 08:00:00,FALSE,57712,2020-03-01 00:00:00 | ||
| 735542695,2022377955,2020-01-06 10:00:00,TRUE,57712,2020-03-01 00:00:00 | ||
| 735542695,2022377955,2020-01-08 16:00:00,FALSE,57712,2020-03-01 00:00:00 | ||
| 735542695,2022377955,2020-01-09 12:00:00,FALSE,57712,2020-03-01 00:00:00 | ||
| 595308957,2059419268,2019-12-10 13:00:00,TRUE,1261230,2020-03-01 00:00:00 | ||
| 595308957,2059419268,2019-12-20 17:45:00,FALSE,2722259,2020-03-01 00:00:00 | ||
| 595308957,2059419264,2019-12-11 09:30:00,TRUE,1261230,2020-03-01 00:00:00 | ||
| 592970298,2022377951,2019-03-05 10:00:00,TRUE,5175328,2020-03-01 00:00:00 | ||
| 595308957,,2019-12-10 13:00:00,TRUE,1261230,2020-02-15 00:00:00 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| {{ config( | ||
| tags="fivetran_validations", | ||
| enabled=var('fivetran_validation_tests_enabled', false) and var('github__using_issue_label_history', true) | ||
| ) }} | ||
|
|
||
| {% set exclude_cols = var('gh_consistency_exclude_columns', []) %} | ||
|
|
||
| -- this test ensures the github__issue_label_history end model matches the prior version | ||
| with prod as ( | ||
| select {{ dbt_utils.star(from=ref('github__issue_label_history'), except=exclude_cols) }} | ||
| from {{ target.schema }}_github_prod.github__issue_label_history | ||
| ), | ||
|
|
||
| dev as ( | ||
| select {{ dbt_utils.star(from=ref('github__issue_label_history'), except=exclude_cols) }} | ||
| from {{ target.schema }}_github_dev.github__issue_label_history | ||
| ), | ||
|
|
||
| prod_not_in_dev as ( | ||
| -- rows from prod not found in dev | ||
| select * from prod | ||
| except distinct | ||
| select * from dev | ||
| ), | ||
|
|
||
| dev_not_in_prod as ( | ||
| -- rows from dev not found in prod | ||
| select * from dev | ||
| except distinct | ||
| select * from prod | ||
| ), | ||
|
|
||
| final as ( | ||
| select | ||
| *, | ||
| 'from prod' as source | ||
| from prod_not_in_dev | ||
|
|
||
| union all -- union since we only care if rows are produced | ||
|
|
||
| select | ||
| *, | ||
| 'from dev' as source | ||
| from dev_not_in_prod | ||
| ) | ||
|
|
||
| select * | ||
| from final |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| {% macro get_issue_label_history_columns() %} | ||
|
|
||
| {% set columns = [ | ||
| {"name": "_fivetran_synced", "datatype": dbt.type_timestamp()}, | ||
| {"name": "actor_id", "datatype": dbt.type_int()}, | ||
| {"name": "issue_id", "datatype": dbt.type_int()}, | ||
| {"name": "label_id", "datatype": dbt.type_int()}, | ||
| {"name": "labeled", "datatype": "boolean"}, | ||
| {"name": "updated_at", "datatype": dbt.type_timestamp()} | ||
| ] %} | ||
|
|
||
| {{ return(columns) }} | ||
|
|
||
| {% endmacro %} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,7 @@ | ||
| {% docs source_relation %} Identifies the record's source. {% enddocs %} | ||
| {% docs source_relation %} Identifies the record's source. {% enddocs %} | ||
|
|
||
| {% docs issue_id %} Foreign key that references the issue table. The issue can be a regular issue or a pull request. {% enddocs %} | ||
|
|
||
| {% docs label_id %} Foreign key that references the label table. {% enddocs %} | ||
|
|
||
| {% docs _fivetran_synced %} Timestamp of the record being synced by Fivetran. {% enddocs %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could probably combine these
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't they usually get their own entries?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we're not consistent. Combined them.