def get_old_tasks(j, project, assignees, max_age, max_results): """ Search in jira tasks with a big testing timeout :param j: Jira instance :param project: Jira project name :param assignees: team members list :param max_age: maximum testing timeout value in days :param max_results: maximum number of tasks returned :return: list of jira tasks """ who = get_jira_list(assignees) old_tasks = j.search_issues( ( f'project = {project} ' f'AND status = Testing ' f'AND assignee IN ({who}) ' f'AND status CHANGED TO Testing BEFORE -{max_age}d ' ), maxResults=settings.MAX_RESULTS, fields='summary,assignee,reporter', expand='changelog', ) def sort_key(issue): for histories in issue.changelog.histories[::-1]: for history in histories.items: if history.toString == 'Testing': return histories.created return datetime.datetime.now() return sorted(old_tasks, key=sort_key)[:max_results]
def get_bugs(j, project, assignees): who = get_jira_list(assignees) bugs = j.search_issues( ( f'project = {project} ' f'AND issuetype = Bug ' f'AND assignee IN ({who}) ' f'AND status = Testing ' ), maxResults=settings.MAX_RESULTS, fields='summary,assignee,reporter', ) return bugs
def get_critical_tasks(j, project, assignees): assignees = get_jira_list(assignees) critical_tasks = j.search_issues( ( f'project = {project} ' f'AND Status = Testing ' f'AND assignee IN ({assignees}) ' f'AND priority = Критический ' ), maxResults=settings.MAX_RESULTS, fields='summary,assignee,reporter', ) return critical_tasks
def get_testing_issues(j, project, assignees, **kwargs): """ :param j: jira instance to request to :param project: project short-name in jira :param assignees: team members list :return: """ testing_issues = j.search_issues( ('project = {project} ' 'AND status = Testing ' 'AND assignee in ({assignees}) ').format( project=project, assignees=get_jira_list(assignees), ), maxResults=settings.MAX_RESULTS, ) return testing_issues
def get_closed_bugs(j, project, assignees, iteration_length): """ Get bugs closed in last iteration :param j: jira instance to request to :param project: project short-name in jira :param assignees: team members list :param iteration_length: iteration length in days :return: list of jira issues """ closed_bugs = j.search_issues( ('project = {project} ' 'AND issuetype = Bug ' 'AND status changed to Closed DURING({period}) ' 'AND assignee WAS in ({assignees})').format( project=project, assignees=get_jira_list(assignees), period=ITERATION.format(iteration_length), ), maxResults=settings.MAX_RESULTS, ) return closed_bugs
def get_weekly_issues(j, project, assignees, iteration_length): """ Get all issues from Jira where any of testing team members marked as an assignee :param j: jira instance to request to :param project: project short-name in jira :param assignees: team members list :param iteration_length: iteration length in days :return: list of jira issues """ weekly_issues = j.search_issues( ( 'project = {project} AND status was Testing DURING ({period}) ' # a bit of Jira jql hacks 'AND assignee WAS IN ({assignees}) DURING ({period}) ').format( project=project, assignees=get_jira_list(assignees), period=ITERATION.format(iteration_length), ), fields='summary', expand='changelog', maxResults=settings.MAX_RESULTS, ) return weekly_issues