-
Notifications
You must be signed in to change notification settings - Fork 0
feat(elt-pipelines) - Add transform method to get times spent in status per issue #461
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
base: main
Are you sure you want to change the base?
Changes from all commits
1b0c2bf
aaa3a3d
3b12e25
2585b8d
fdca41d
ee0bbbf
df1a619
09cccef
e889c3a
4566708
d35b806
6dc6e00
288aa07
7666d1c
008c5a4
adb2d3d
2628606
e409888
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,43 @@ | ||
| -- Get the differences between the status. No need for final status, so this query is perfectly suitable | ||
| with status_to_from as ( | ||
| select | ||
| issue_key, | ||
| from_status as status, | ||
| lag(changed_at) over (partition by issue_key order by changed_at) as status_from, | ||
| changed_at as status_to | ||
| from {{ ref('stg_jira_issue_status_changelogs') }} as changelogs | ||
| ), | ||
|
|
||
| -- Populate null values of status from with the issue creation date. Join required | ||
| nn_status_to_from as ( | ||
| select | ||
| status_to_from.issue_key, | ||
| status_to_from.status, | ||
| COALESCE(status_to_from.status_from, issues.created) as status_from, | ||
| status_to_from.status_to | ||
| from status_to_from | ||
| inner join facility_ops_landing.computing_jira.isis_jira_issues as issues | ||
| on status_to_from.issue_key = issues.issue_key | ||
| ), | ||
|
|
||
| -- Subtract to and from date | ||
| status_durations as ( | ||
| select | ||
| issue_key, | ||
| status, | ||
| date_diff('second', status_from, status_to) as status_duration | ||
| from nn_status_to_from | ||
| ), | ||
|
|
||
| -- Aggregate similar statuses and add their durations | ||
| times_in_status as ( | ||
| select | ||
| issue_key, | ||
| status, | ||
| sum(status_duration) as time_in_status | ||
| from status_durations | ||
| group by issue_key, | ||
| status | ||
| ) | ||
|
|
||
| select * from times_in_status | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| with times_in_status as ( | ||
|
Member
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. This is not something you could have known but can you include to the top of each of the |
||
| select * from {{ ref('int_times_in_status') }} where issue_key like 'CI-%' | ||
| ), | ||
|
|
||
| time_in_status_data_driven_facility as ( | ||
| select | ||
| issue_key, | ||
| MAX( | ||
|
Member
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. I think I confused things with the original issue having a single table and then changing it to separate tables. Can we just include the statuses, column names on the boards, in the statuses here and for all of the projects? Over time we might migrate to a common set across the projects. |
||
| case | ||
| when status = 'analyzing' then time_in_status | ||
| else null | ||
| end | ||
| ) as time_in_analysing_secs, | ||
| MAX( | ||
| case | ||
| when status = 'backlog' then time_in_status | ||
| else null | ||
| end | ||
| ) as time_in_backlog_secs, | ||
| MAX( | ||
| case | ||
| when status = 'done' then time_in_status | ||
| else null | ||
| end | ||
| ) as time_in_done_secs, | ||
| MAX( | ||
| case | ||
| when status = 'funnel' then time_in_status | ||
| else null | ||
| end | ||
| ) as time_in_funnel_secs, | ||
| MAX( | ||
| case | ||
| when status = 'implementing' then time_in_status | ||
| else null | ||
| end | ||
| ) as time_in_implementing_secs, | ||
| MAX( | ||
| case | ||
| when status = 'implementing (mvp)' then time_in_status | ||
| else null | ||
| end | ||
| ) as time_in_implementing_mvp_secs, | ||
| MAX( | ||
| case | ||
| when status = 'implementing (persevere)' then time_in_status | ||
| else null | ||
| end | ||
| ) as time_in_implementing_persevere_secs, | ||
| MAX( | ||
| case | ||
| when status = 'in progress' then time_in_status | ||
| else null | ||
| end | ||
| ) as time_in_in_progress_secs, | ||
| MAX( | ||
| case | ||
| when status = 'portfolio backlog' then time_in_status | ||
| else null | ||
| end | ||
| ) as time_in_portfolio_backlog_secs, | ||
| MAX( | ||
| case | ||
| when status = 'ready' then time_in_status | ||
| else null | ||
| end | ||
| ) as time_in_ready_secs, | ||
| MAX( | ||
| case | ||
| when status = 'reviewing' then time_in_status | ||
| else null | ||
| end | ||
| ) as time_in_reviewing_secs | ||
| from times_in_status | ||
| group by issue_key | ||
|
|
||
| ) | ||
| select * from time_in_status_data_driven_facility | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| models: | ||
| - name: time_spent_in_status | ||
| description: > | ||
| Get length of time an issue spends in each status for user software issues. | ||
| columns: | ||
| - name: issue_key | ||
| data_tests: | ||
| - not_null | ||
|
Comment on lines
+2
to
+8
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. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win Use the SQL model names in both schema patches.
📍 Affects 2 files
🤖 Prompt for AI Agents |
||
| - name: time_in_analysing_secs | ||
| - name: time_in_backlog_secs | ||
| - name: time_in_done_secs | ||
| - name: time_in_funnel_secs | ||
| - name: time_in_implementing_secs | ||
| - name: time_in_implementing_mvp_secs | ||
| - name: time_in_implementing_persevere_secs | ||
| - name: time_in_in_progress_secs | ||
| - name: time_in_portfolio_backlog_secs | ||
| - name: time_in_ready_secs | ||
| - name: time_in_reviewing_secs | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| with times_in_status as ( | ||
| select * from {{ ref('int_times_in_status') }} where issue_key like 'DD-%' | ||
| ), | ||
|
|
||
| time_in_status_data_driven_facility as ( | ||
| select | ||
| issue_key, | ||
| MAX( | ||
| case | ||
| when status = 'analyzing' then time_in_status | ||
| else null | ||
| end | ||
| ) as time_in_analysing_secs, | ||
| MAX( | ||
| case | ||
| when status = 'backlog' then time_in_status | ||
| else null | ||
| end | ||
| ) as time_in_backlog_secs, | ||
| MAX( | ||
| case | ||
| when status = 'done' then time_in_status | ||
| else null | ||
| end | ||
| ) as time_in_done_secs, | ||
| MAX( | ||
| case | ||
| when status = 'funnel' then time_in_status | ||
| else null | ||
| end | ||
| ) as time_in_funnel_secs, | ||
| MAX( | ||
| case | ||
| when status = 'implementing' then time_in_status | ||
| else null | ||
| end | ||
| ) as time_in_implementing_secs, | ||
| MAX( | ||
| case | ||
| when status = 'implementing (mvp)' then time_in_status | ||
| else null | ||
| end | ||
| ) as time_in_implementing_mvp_secs, | ||
| MAX( | ||
| case | ||
| when status = 'implementing (persevere)' then time_in_status | ||
| else null | ||
| end | ||
| ) as time_in_implementing_persevere_secs, | ||
| MAX( | ||
| case | ||
| when status = 'in progress' then time_in_status | ||
| else null | ||
| end | ||
| ) as time_in_in_progress_secs, | ||
| MAX( | ||
| case | ||
| when status = 'portfolio backlog' then time_in_status | ||
| else null | ||
| end | ||
| ) as time_in_portfolio_backlog_secs, | ||
| MAX( | ||
| case | ||
| when status = 'ready' then time_in_status | ||
| else null | ||
| end | ||
| ) as time_in_ready_secs, | ||
| MAX( | ||
| case | ||
| when status = 'reviewing' then time_in_status | ||
| else null | ||
| end | ||
| ) as time_in_reviewing_secs, | ||
| MAX( | ||
| case | ||
| when status = 'selected for development' then time_in_status | ||
| else null | ||
| end | ||
| ) as time_in_selected_for_development_secs | ||
| from times_in_status | ||
| group by issue_key | ||
|
|
||
| ) | ||
| select * from time_in_status_data_driven_facility |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| models: | ||
| - name: time_spent_in_status | ||
| description: > | ||
| Get length of time an issue spends in each status for user software issues. | ||
| columns: | ||
| - name: issue_key | ||
| data_tests: | ||
| - not_null | ||
| - name: time_in_analysing_secs | ||
| - name: time_in_backlog_secs | ||
| - name: time_in_done_secs | ||
| - name: time_in_funnel_secs | ||
| - name: time_in_implementing_secs | ||
| - name: time_in_implementing_mvp_secs | ||
| - name: time_in_implementing_persevere_secs | ||
| - name: time_in_in_progress_secs | ||
| - name: time_in_portfolio_backlog_secs | ||
| - name: time_in_ready_secs | ||
| - name: time_in_reviewing_secs | ||
| - name: time_in_selected_for_development_secs |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| with times_in_status as ( | ||
| select * from {{ ref('int_times_in_status') }} where issue_key like 'SS-%' | ||
| ), | ||
|
|
||
| time_in_status_scientific_software as ( | ||
| select | ||
| issue_key, | ||
| MAX( | ||
| case | ||
| when status = 'analyzing' then time_in_status | ||
| else null | ||
| end | ||
| ) as time_in_analysing_secs, | ||
| MAX( | ||
| case | ||
| when status = 'backlog' then time_in_status | ||
| else null | ||
| end | ||
| ) as time_in_backlog_secs, | ||
| MAX( | ||
| case | ||
| when status = 'done' then time_in_status | ||
| else null | ||
| end | ||
| ) as time_in_done_secs, | ||
| MAX( | ||
| case | ||
| when status = 'funnel' then time_in_status | ||
| else null | ||
| end | ||
| ) as time_in_funnel_secs, | ||
| MAX( | ||
| case | ||
| when status = 'implementing' then time_in_status | ||
| else null | ||
| end | ||
| ) as time_in_implementing_secs, | ||
| MAX( | ||
| case | ||
| when status = 'implementing (mvp)' then time_in_status | ||
| else null | ||
| end | ||
| ) as time_in_implementing_mvp_secs, | ||
| MAX( | ||
| case | ||
| when status = 'implementing (persevere)' then time_in_status | ||
| else null | ||
| end | ||
| ) as time_in_implementing_persevere_secs, | ||
| MAX( | ||
| case | ||
| when status = 'in progress' then time_in_status | ||
| else null | ||
| end | ||
| ) as time_in_in_progress_secs, | ||
| MAX( | ||
| case | ||
| when status = 'portfolio backlog' then time_in_status | ||
| else null | ||
| end | ||
| ) as time_in_portfolio_backlog_secs, | ||
| MAX( | ||
| case | ||
| when status = 'ready' then time_in_status | ||
| else null | ||
| end | ||
| ) as time_in_ready_secs, | ||
| MAX( | ||
| case | ||
| when status = 'reviewing' then time_in_status | ||
| else null | ||
| end | ||
| ) as time_in_reviewing_secs | ||
| from times_in_status | ||
| group by issue_key | ||
|
|
||
| ) | ||
| select * from time_in_status_scientific_software |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| models: | ||
| - name: time_spent_in_status | ||
|
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. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n -C 2 \
'name:[[:space:]]*(time_spent_in_status|time_in_status_scientific_software|time_in_status_user_software)' \
elt-pipelines/facility_ops/transform/models/marts/computing/time_in_status_scientific_software.yml \
elt-pipelines/facility_ops/transform/models/marts/computing/time_in_status_user_software.ymlRepository: ISISNeutronMuon/analytics-data-platform Length of output: 1218 🏁 Script executed: #!/bin/bash
set -euo pipefail
for f in \
elt-pipelines/facility_ops/transform/models/marts/computing/time_in_status_scientific_software.sql \
elt-pipelines/facility_ops/transform/models/marts/computing/time_in_status_user_software.sql \
elt-pipelines/facility_ops/transform/models/marts/computing/time_in_status_scientific_software.yml \
elt-pipelines/facility_ops/transform/models/marts/computing/time_in_status_user_software.yml
do
printf '\n--- %s ---\n' "$f"
sed -n '1,120p' "$f"
doneRepository: ISISNeutronMuon/analytics-data-platform Length of output: 6088 Attach each schema file to its dbt model. The schema entries use
📍 Affects 2 files
🤖 Prompt for AI Agents |
||
| description: > | ||
| Get length of time an issue spends in each status | ||
| columns: | ||
| - name: issue_key | ||
| data_tests: | ||
| - not_null | ||
| - name: time_in_analysing_secs | ||
| - name: time_in_backlog_secs | ||
| - name: time_in_done_secs | ||
| - name: time_in_funnel_secs | ||
| - name: time_in_implementing_secs | ||
| - name: time_in_implementing_mvp_secs | ||
| - name: time_in_implementing_persevere_secs | ||
| - name: time_in_in_progress_secs | ||
| - name: time_in_portfolio_backlog_secs | ||
| - name: time_in_ready_secs | ||
| - name: time_in_reviewing_secs | ||
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.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Materialise the final status interval and retain no-transition issues.
status_to_fromemits onlyfrom_statusrows from the changelog, so it omits the staged issue's currentstatusafter the last transition. A terminal row alone does not restore issues with no transitions because the model starts from the changelog. Build fromstg_jira_isis_jira_issues, usecreated_atfor no-transition issues, and add a current-time terminal boundary for the currentstatus. The mart schema requires a non-nullissue_key, but it does not explicitly require complete staged-issue coverage.🤖 Prompt for AI Agents