Minor enhancements
This commit is contained in:
+64
-50
@@ -8,55 +8,60 @@ import csv
|
||||
import xlsxwriter
|
||||
import logging
|
||||
|
||||
def get_assignee(type):
|
||||
def get_assignee(type, issue):
|
||||
isBuergerfrontend = False
|
||||
if type == 'Dev Backend':
|
||||
#return 'rab9001'
|
||||
return 'reu9001'
|
||||
elif type == 'Dev Frontend':
|
||||
# consider verwaltungsfrontend or bürgerfrontend
|
||||
for component in issue.fields.components:
|
||||
isBuergerfrontend = component.name == "Bürgerfrontend"
|
||||
if isBuergerfrontend:
|
||||
return 'reu9001'
|
||||
return 'thh9001'
|
||||
# return 'reu9001'
|
||||
elif type[:14] == 'Test-Anpassung':
|
||||
elif type.startswith('Test-Anpassung'):
|
||||
return 'ada9001'
|
||||
|
||||
def create_subtask(issue, parent, type, subtask_sp):
|
||||
escaped = issue.fields.summary.replace('"','\\"')
|
||||
print('summary ~ \"{}\"'.format(escaped))
|
||||
|
||||
subtask = jira_server.search_issues('summary ~ \"{} {}\"'.format(type, escaped))
|
||||
if len(subtask) == 0:
|
||||
#right = (comment_line.find(':')+2)-len(comment_line)
|
||||
#subtask_sp = float(comment_line[right:])
|
||||
|
||||
# issuetype of testcase-creation/modification should be 'Test'
|
||||
# if type == 'Test-Anpassung':
|
||||
issue_type = 'Sub-task'
|
||||
def create_subtask(issue, parent, type, subtask_sp, estimation_remark):
|
||||
escaped = issue.fields.summary.replace('"', r'\"')
|
||||
logging.info(f'summary ~ \"{escaped}\"')
|
||||
|
||||
assignee = get_assignee(type)
|
||||
issue_dict = {
|
||||
'project': {'id': 12501},
|
||||
'summary': "[{}] {}".format(type, escaped),
|
||||
'description': issue.fields.description,
|
||||
'issuetype': {'name': issue_type},
|
||||
'priority': {'name': issue.fields.priority.name},
|
||||
'parent': {'key': parent},
|
||||
'labels': issue.fields.labels,
|
||||
#'customfield_10022' - Story Points
|
||||
'timetracking': {'originalEstimate': "{}d".format(subtask_sp)},
|
||||
'assignee': {'name': assignee}
|
||||
}
|
||||
new_issue = jira_server.create_issue(fields=issue_dict)
|
||||
try:
|
||||
subtask = jira_server.search_issues(f'summary ~ \"{type} {escaped}\"')
|
||||
if subtask:
|
||||
raise exceptions.JIRAError
|
||||
except exceptions.JIRAError:
|
||||
logging.info(f'Skip creating Sub-Task {type} for {issue} as it already exists')
|
||||
return
|
||||
|
||||
# consider components
|
||||
existingComponents = []
|
||||
for component in issue.fields.components:
|
||||
existingComponents.append({"name" : component.name})
|
||||
new_issue.update(fields={"components": existingComponents})
|
||||
#new_issue.update(priority={"name": issue.fields.priority.name})
|
||||
issue_type = 'Sub-task'
|
||||
|
||||
logging.info('Created Sub-Task {}'.format(new_issue))
|
||||
else:
|
||||
logging.info('Skip creating Sub-Task {} for {} as it already exists'.format(type, issue))
|
||||
assignee = get_assignee(type, issue)
|
||||
description = 's. Story'
|
||||
if estimation_remark != "":
|
||||
description += "\nEstimation remark: {}".format(estimation_remark)
|
||||
|
||||
issue_dict = {
|
||||
'project': {'id': issue.fields.project.id},
|
||||
'summary': "[{}] {}".format(type, escaped),
|
||||
'description': description, # issue.fields.description,
|
||||
'issuetype': {'name': issue_type},
|
||||
'priority': {'name': issue.fields.priority.name},
|
||||
'parent': {'key': parent},
|
||||
'labels': issue.fields.labels,
|
||||
#'customfield_10022' - Story Points
|
||||
'timetracking': {'originalEstimate': "{}d".format(subtask_sp)},
|
||||
'assignee': {'name': assignee}
|
||||
}
|
||||
new_issue = jira_server.create_issue(fields=issue_dict)
|
||||
|
||||
# consider components
|
||||
existingComponents = []
|
||||
for component in issue.fields.components:
|
||||
existingComponents.append({"name" : component.name})
|
||||
new_issue.update(fields={"components": existingComponents})
|
||||
#new_issue.update(priority={"name": issue.fields.priority.name})
|
||||
|
||||
logging.info('Created Sub-Task {}'.format(new_issue))
|
||||
|
||||
logging.basicConfig(filename='sub_task_generator.log',
|
||||
filemode='a',
|
||||
@@ -66,15 +71,15 @@ logging.basicConfig(filename='sub_task_generator.log',
|
||||
|
||||
host = "https://jira.wien.gv.at/"
|
||||
pat = "OTAyMTM3MjY0MjE0Ovz6bu0ti1TlEdSegmmiWiJ2wGeD"
|
||||
sprint = 46
|
||||
sprint = 4
|
||||
|
||||
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=20406') #, expand='changelog')
|
||||
#issues_Jql = jira_server.search_issues('key in (WRGWR-1558)') #, expand='changelog')
|
||||
issues_Jql = jira_server.search_issues('filter=22140') #, expand='changelog')
|
||||
#issues_Jql = jira_server.search_issues('key in (DKARB-34)') #, 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))
|
||||
@@ -110,20 +115,29 @@ for issue in issues_Jql:
|
||||
# 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
|
||||
subtask_ph = float(comment_line_parts[1]) * 0.5
|
||||
if (comment_line_parts[1][-2:] != 'NN') and (comment_line_parts[1][-1:] != '-'): # NN means NotNecessary
|
||||
comment_line_sub_parts = comment_line_parts[1].split(' (')
|
||||
if len(comment_line_sub_parts)>1:
|
||||
subtask_ph = float(comment_line_sub_parts[0]) * 0.5
|
||||
estimation_remark = comment_line_sub_parts[1]
|
||||
else:
|
||||
subtask_ph = float(comment_line_parts[1]) * 0.5
|
||||
estimation_remark = ""
|
||||
|
||||
if comment_line_parts[0][:15] != "Test-Ausführung":
|
||||
create_subtask(issue,
|
||||
issue.key,
|
||||
comment_line_parts[0],
|
||||
subtask_ph)
|
||||
issue.key,
|
||||
comment_line_parts[0],
|
||||
subtask_ph,
|
||||
estimation_remark)
|
||||
sp_sum += subtask_ph / 0.5
|
||||
|
||||
# find corresponding sub-task
|
||||
# issuelinks.inwardIssue
|
||||
try:
|
||||
issue.update(fields={'customfield_10022': sp_sum})
|
||||
logging.info("Estimated story-points changed to Sum(Sub-Tasks story-points): {}".format(sp_sum, sp_sum))
|
||||
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))
|
||||
|
||||
Reference in New Issue
Block a user