← Back to team overview

sts-sponsors team mailing list archive

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

 

Adam Collard has proposed merging ~adam-collard/maas/+git/maas-release-tools:wsjfify-fix into ~maas-committers/maas/+git/maas-release-tools:main.

Commit message:
Blacklist customfield_10348 for story points name collision



Requested reviews:
  MAAS Committers (maas-committers)

For more details, see:
https://code.launchpad.net/~adam-collard/maas/+git/maas-release-tools/+merge/439737
-- 
Your team MAAS Committers is requested to review the proposed merge of ~adam-collard/maas/+git/maas-release-tools:wsjfify-fix into ~maas-committers/maas/+git/maas-release-tools:main.
diff --git a/maas_release_tools/scripts/wsjfify.py b/maas_release_tools/scripts/wsjfify.py
index d9bcbdd..267c2b1 100644
--- a/maas_release_tools/scripts/wsjfify.py
+++ b/maas_release_tools/scripts/wsjfify.py
@@ -1,6 +1,5 @@
 """Recalculate WSJF for tickets with Cost of Delay and Story Points."""
 
-
 import argparse
 import json
 
@@ -48,9 +47,9 @@ def find_estimated_issues(jira, project, component):
 
 
 def calculate_wsjf(issue):
-    return round(
-        issue.fields["cost_of_delay"] / issue.fields["story_points"], 3
-    )
+    cod = issue.fields["cost_of_delay"]
+    story_points = issue.fields["story_points"]
+    return round(cod / story_points, 3)
 
 
 def pythonise_propertyholder(fields_by_name):
@@ -79,16 +78,24 @@ def main():
     def slugify(name):
         return name.lower().replace(" ", "_").replace("-", "_")
 
+    # slugify can cause fields to be ambiguous, and can end up using
+    # the wrong one. Blacklist some known failures.
+    blacklist_ids = {"customfield_10348"}  # story points
     fields_by_name = {
-        slugify(field["name"]): field["id"] for field in all_fields
+        slugify(field["name"]): field["id"]
+        for field in all_fields
+        if field["id"] not in blacklist_ids
     }
-
     # Make the fields dict-like and friendly
     pythonise_propertyholder(fields_by_name)
 
     for issue in find_estimated_issues(jira, project="PF", component="MAAS"):
         existing_wsjf = issue.fields["wsjf"]
-        wsjf = calculate_wsjf(issue)
+        try:
+            wsjf = calculate_wsjf(issue)
+        except KeyError as ke:
+            print(f"Failed calculating WSJF for {issue.key} {ke}")
+            raise
         if wsjf != existing_wsjf:
             print(
                 f"[{issue.key}] setting WSJF to {wsjf} (was {existing_wsjf})"

Follow ups