Merge ~adam-collard/maas/+git/maas-release-tools:wsjfify-fix into ~maas-committers/maas/+git/maas-release-tools:main

Proposed by Adam Collard
Status: Merged
Approved by: Adam Collard
Approved revision: a09849f478ce689a6a8c93de9e612fcdf7f6db93
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~adam-collard/maas/+git/maas-release-tools:wsjfify-fix
Merge into: ~maas-committers/maas/+git/maas-release-tools:main
Diff against target: 52 lines (+14/-7)
1 file modified
maas_release_tools/scripts/wsjfify.py (+14/-7)
Reviewer Review Type Date Requested Status
MAAS Lander Approve
MAAS Committers Pending
Review via email: mp+439737@code.launchpad.net

Commit message

Blacklist customfield_10348 for story points name collision

To post a comment you must log in.
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b wsjfify-fix lp:~adam-collard/maas/+git/maas-release-tools into -b main lp:~maas-committers/maas/+git/maas-release-tools

STATUS: SUCCESS
COMMIT: a09849f478ce689a6a8c93de9e612fcdf7f6db93

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/maas_release_tools/scripts/wsjfify.py b/maas_release_tools/scripts/wsjfify.py
2index d9bcbdd..267c2b1 100644
3--- a/maas_release_tools/scripts/wsjfify.py
4+++ b/maas_release_tools/scripts/wsjfify.py
5@@ -1,6 +1,5 @@
6 """Recalculate WSJF for tickets with Cost of Delay and Story Points."""
7
8-
9 import argparse
10 import json
11
12@@ -48,9 +47,9 @@ def find_estimated_issues(jira, project, component):
13
14
15 def calculate_wsjf(issue):
16- return round(
17- issue.fields["cost_of_delay"] / issue.fields["story_points"], 3
18- )
19+ cod = issue.fields["cost_of_delay"]
20+ story_points = issue.fields["story_points"]
21+ return round(cod / story_points, 3)
22
23
24 def pythonise_propertyholder(fields_by_name):
25@@ -79,16 +78,24 @@ def main():
26 def slugify(name):
27 return name.lower().replace(" ", "_").replace("-", "_")
28
29+ # slugify can cause fields to be ambiguous, and can end up using
30+ # the wrong one. Blacklist some known failures.
31+ blacklist_ids = {"customfield_10348"} # story points
32 fields_by_name = {
33- slugify(field["name"]): field["id"] for field in all_fields
34+ slugify(field["name"]): field["id"]
35+ for field in all_fields
36+ if field["id"] not in blacklist_ids
37 }
38-
39 # Make the fields dict-like and friendly
40 pythonise_propertyholder(fields_by_name)
41
42 for issue in find_estimated_issues(jira, project="PF", component="MAAS"):
43 existing_wsjf = issue.fields["wsjf"]
44- wsjf = calculate_wsjf(issue)
45+ try:
46+ wsjf = calculate_wsjf(issue)
47+ except KeyError as ke:
48+ print(f"Failed calculating WSJF for {issue.key} {ke}")
49+ raise
50 if wsjf != existing_wsjf:
51 print(
52 f"[{issue.key}] setting WSJF to {wsjf} (was {existing_wsjf})"

Subscribers

People subscribed via source and target branches

to all changes: