Several enhancements
This commit is contained in:
+64
-59
@@ -9,6 +9,7 @@ import csv
|
||||
import xlsxwriter
|
||||
import logging
|
||||
from bisect import bisect_left
|
||||
from datetime import date
|
||||
|
||||
def take_closest(myList, myNumber):
|
||||
"""
|
||||
@@ -29,15 +30,18 @@ def take_closest(myList, myNumber):
|
||||
return before
|
||||
|
||||
def get_assignee(type, issue):
|
||||
isBuergerfrontend = False
|
||||
if type == 'Dev Backend':
|
||||
return 'reu9001'
|
||||
# isBuergerfrontend = False
|
||||
if (type == 'Dev Backend' or type.startswith('Dev Unit')):
|
||||
# use assignee of story
|
||||
return 'rab9001'
|
||||
#return issue.fields.assignee.name
|
||||
elif type == 'Dev Frontend':
|
||||
for component in issue.fields.components:
|
||||
isBuergerfrontend = component.name == "Bürgerfrontend"
|
||||
if isBuergerfrontend:
|
||||
return 'reu9001'
|
||||
# for component in issue.fields.components:
|
||||
# isBuergerfrontend = component.name == "Bürgerfrontend"
|
||||
# if isBuergerfrontend:
|
||||
return 'thh9001'
|
||||
elif type == 'Dev Citizen-Frontend':
|
||||
return 'reu9001'
|
||||
elif type.startswith('Test-Anpassung'):
|
||||
return 'osm9005'
|
||||
|
||||
@@ -99,18 +103,18 @@ logging.basicConfig(filename='sub_task_generator.log',
|
||||
|
||||
host = "https://jira.wien.gv.at/"
|
||||
pat = "OTAyMTM3MjY0MjE0Ovz6bu0ti1TlEdSegmmiWiJ2wGeD"
|
||||
sprint = 4
|
||||
sprint = 6
|
||||
|
||||
headers = JIRA.DEFAULT_OPTIONS["headers"].copy()
|
||||
headers["Authorization"] = f"Bearer {pat}"
|
||||
jira_server = JIRA(server=host, options={"headers": headers})
|
||||
|
||||
# use filter or single issue
|
||||
issues_Jql = jira_server.search_issues('filter=25827') #, expand='changelog')
|
||||
#issues_Jql = jira_server.search_issues('key in (WRWGR-2885)') #, expand='changelog')
|
||||
#issues_Jql = jira_server.search_issues('filter=25827') #, expand='changelog')
|
||||
issues_Jql = jira_server.search_issues('key in (WRGWR-2932)') #, expand='changelog')
|
||||
#issues_Jql = jira_server.search_issues('labels in (Refinement11012022) AND type not in (Bug) AND status not in (Done) and ("Story Points" is EMPTY or "Story Points" = 0)') #, expand='changelog')
|
||||
|
||||
logging.info('Creating sub-tasks out of estimation of pre-planning sprint {}'.format(sprint))
|
||||
logging.info(f'Creating sub-tasks out of estimation of pre-planning of {date.today()}')
|
||||
xsp = lambda s: s or 0
|
||||
|
||||
issue: Issue
|
||||
@@ -123,63 +127,64 @@ for issue in issues_Jql:
|
||||
if hasattr(issue.fields, 'customfield_10022'):
|
||||
sp = xsp(issue.fields.customfield_10022)
|
||||
|
||||
if sp != 0:
|
||||
logging.info('Ignoring issue {} as there are Story-Points already omitted'.format(issue))
|
||||
else:
|
||||
single_issue = jira_server.issue(issue.key)
|
||||
comments = single_issue.fields.comment.comments
|
||||
# if sp == 0:
|
||||
# logging.info('Ignoring issue {} as there are Story-Points already omitted'.format(issue))
|
||||
# else:
|
||||
single_issue = jira_server.issue(issue.key)
|
||||
comments = single_issue.fields.comment.comments
|
||||
|
||||
# Find all comments made by me on this issue.
|
||||
for comment in comments:
|
||||
comment_lines = comment.body.splitlines()
|
||||
# Find all comments made by me on this issue.
|
||||
for comment in comments:
|
||||
comment_lines = comment.body.splitlines()
|
||||
|
||||
if len(comment_lines) == 7:
|
||||
if comment_lines[0][:5] == "Dev B":
|
||||
for comment_line in comment_lines:
|
||||
if comment_line != "":
|
||||
# pos = comment_lines[2].find('NN')
|
||||
comment_line_parts = comment_line.split(':')
|
||||
if len(comment_lines) == 9:
|
||||
if comment_lines[0][:5] == "Dev B":
|
||||
for comment_line in comment_lines:
|
||||
if comment_line != "":
|
||||
# pos = comment_lines[2].find('NN')
|
||||
comment_line_parts = comment_line.split(':')
|
||||
|
||||
# if 1. Test* != NN create a sub-task (if not existing)
|
||||
if len(comment_line_parts) == 2:
|
||||
if comment_line_parts[1] != u'\xa0': # empty string
|
||||
if (comment_line_parts[1][-2:] != 'NN'): # NN means NotNecessary
|
||||
if (comment_line_parts[1][-1:] == '-'):
|
||||
subtask_ph = 0
|
||||
estimation_remark = "(not estimated yet)"
|
||||
else:
|
||||
comment_line_sub_parts = comment_line_parts[1].split(' (')
|
||||
if len(comment_line_sub_parts)>1:
|
||||
# if 1. Test* != NN create a sub-task (if not existing)
|
||||
if len(comment_line_parts) == 2:
|
||||
if comment_line_parts[1] != u'\xa0': # empty string
|
||||
if (comment_line_parts[1][-2:] != 'NN'): # NN means NotNecessary, "-"" means we don't know yet (but subtask will be created)
|
||||
if (comment_line_parts[1][-1:] == '-'):
|
||||
subtask_ph = 0
|
||||
estimation_remark = "(not estimated yet)"
|
||||
else:
|
||||
comment_line_sub_parts = comment_line_parts[1].split(' (')
|
||||
if len(comment_line_sub_parts)>1:
|
||||
if comment_line_sub_parts[0].strip().isnumeric():
|
||||
subtask_ph = float(comment_line_sub_parts[0]) * 0.5
|
||||
estimation_remark = comment_line_sub_parts[1]
|
||||
estimation_remark = comment_line_sub_parts[1]
|
||||
else:
|
||||
if comment_line_sub_parts[0].strip().isnumeric():
|
||||
subtask_ph = float(comment_line_sub_parts[0]) * 0.5
|
||||
estimation_remark = ""
|
||||
else:
|
||||
if comment_line_sub_parts[0].strip().isnumeric():
|
||||
subtask_ph = float(comment_line_sub_parts[0]) * 0.5
|
||||
estimation_remark = ""
|
||||
else:
|
||||
if comment_line_sub_parts[0].strip() == "tbd":
|
||||
subtask_ph = take_closest([1,2,3,5,8,13,21,42], sp_sum/3)
|
||||
if comment_line_sub_parts[0].strip() == "tbd":
|
||||
subtask_ph = take_closest([1,2,3,5,8,13,21,42], sp_sum/3)
|
||||
|
||||
if comment_line_parts[0][:15] != "Test-Ausführung":
|
||||
create_subtask(issue,
|
||||
issue.key,
|
||||
comment_line_parts[0],
|
||||
subtask_ph,
|
||||
estimation_remark)
|
||||
sp_sum += subtask_ph / 0.5
|
||||
if comment_line_parts[0][:15] != "Test-Ausführung":
|
||||
create_subtask(issue,
|
||||
issue.key,
|
||||
comment_line_parts[0],
|
||||
subtask_ph,
|
||||
estimation_remark)
|
||||
sp_sum += subtask_ph / 0.5
|
||||
|
||||
# find corresponding sub-task
|
||||
# issuelinks.inwardIssue
|
||||
try:
|
||||
if sp != sp_sum:
|
||||
issue.update(fields={'customfield_10022': sp_sum})
|
||||
logging.info("Estimated story-points changed to Sum(Sub-Tasks story-points): {}".format(sp_sum, sp_sum))
|
||||
# find corresponding sub-task
|
||||
# issuelinks.inwardIssue
|
||||
try:
|
||||
if sp != sp_sum:
|
||||
issue.update(fields={'customfield_10022': sp_sum})
|
||||
logging.info("Estimated story-points changed to Sum(Sub-Tasks story-points): {}".format(sp_sum, sp_sum))
|
||||
|
||||
except exceptions.JIRAError:
|
||||
logging.error("Issue {} has no (visible) Story Points-attribute".format(issue.key))
|
||||
except exceptions.JIRAError:
|
||||
logging.error("Issue {} has no (visible) Story Points-attribute".format(issue.key))
|
||||
|
||||
finally:
|
||||
logging.info('Done {}'.format(issue.key))
|
||||
finally:
|
||||
logging.info('Done {}'.format(issue.key))
|
||||
|
||||
#print('{}: {}, SP: {}'.format(issue.key, issue.fields.summary, sp))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user