Skip to content
Permalink
Browse files
[FLINK-22569] limit number of tickets touched by the bot per run to 100
  • Loading branch information
knaufk committed May 19, 2021
1 parent 9c2998a commit 59c16f595514c67983965d9580c7c0f45eebcaaf
Showing 2 changed files with 14 additions and 8 deletions.
@@ -17,6 +17,7 @@
################################################################################

stale_assigned:
ticket_limit: 10
stale_days: 14
warning_days: 7
warning_label: "stale-assigned"
@@ -30,6 +31,7 @@ stale_assigned:
This issue was marked "{warning_label}" {warning_days} ago and has not received an update. I have automatically removed the current assignee from the issue so others in the community may pick it up. If you are still working on this ticket, please ask a committer to reassign you and provide an update about your current status.
stale_minor:
ticket_limit: 10
stale_days: 180
warning_days: 7
warning_label: "stale-minor"
@@ -41,6 +43,7 @@ stale_minor:
This issue was labeled "{warning_label}" {warning_days} ago and has not received any updates so I have gone ahead and closed it. If you are still affected by this or would like to raise the priority of this ticket please re-open, removing the label "{done_label}" and raise the ticket priority accordingly.
stale_blocker:
ticket_limit: 5
stale_days: 1
warning_days: 7
warning_label: "stale-blocker"
@@ -52,6 +55,7 @@ stale_blocker:
This issue was labeled "{warning_label}" {warning_days} ago and has not received any updates so it is being deprioritized. If this ticket is actually a Blocker, please raise the priority and ask a committer to assign you the issue or revive the public discussion.
stale_critical:
ticket_limit: 10
stale_days: 7
warning_days: 7
warning_label: "stale-critical"
@@ -63,6 +67,7 @@ stale_critical:
This issue was labeled "{warning_label}" {warning_days} ago and has not received any updates so it is being deprioritized. If this ticket is actually Critical, please raise the priority and ask a committer to assign you the issue or revive the public discussion.
stale_major:
ticket_limit: 15
stale_days: 30
warning_days: 7
warning_label: "stale-major"
@@ -32,32 +32,33 @@ def __init__(self, jira_client, config, is_dry_run):
self.done_label = config["done_label"].get()
self.done_comment = config["done_comment"].get()
self.warning_comment = config["warning_comment"].get()
self.ticket_limit = config["ticket_limit"].get()

def get_issues(self, jql_query):
def get_issues(self, jql_query, limit):
"""Queries the JIRA PI for all issues that match the given JQL Query
This method is necessary as requests tend to time out if the number of results reaches a certain number.
So, this method requests the results in multiple queries and returns a final list of all issues.
:param jql_query: the search query
:return: a list of issues matching the query
"""
limit = 200
limit_per_api_request = min(100, limit)
current = 0
total = 1
issues = []
while current < total:
response = self.jira_client.jql(jql_query, limit=limit, start=current)
while current < min(total, limit):
response = self.jira_client.jql(jql_query, limit=limit_per_api_request, start=current)
total = response["total"]
issues = issues + response["issues"]
current = len(issues)
logging.info(f'"{jql_query}" returned {len(issues)} issues')
return issues
return issues[:min(limit, len(issues))]

def has_recently_updated_subtask(self, parent, updated_within_days):
find_subtasks_updated_within = (
f"parent = {parent} AND updated > startOfDay(-{updated_within_days}d)"
)
issues = self.get_issues(find_subtasks_updated_within)
issues = self.get_issues(find_subtasks_updated_within, 1)
return len(issues) > 0

def add_label_with_comment(self, key, label, comment):
@@ -80,7 +81,7 @@ def handle_stale_ticket(self, key):
def mark_stale_tickets_stale(self, jql_query):

logging.info(f"Looking for stale tickets.")
issues = self.get_issues(jql_query)
issues = self.get_issues(jql_query, self.ticket_limit)

for issue in issues:
key = issue["key"]
@@ -106,7 +107,7 @@ def mark_stale_tickets_stale(self, jql_query):

def handle_tickets_marked_stale(self, jql_query):
logging.info(f"Looking for ticket previously marked as {self.warning_label}.")
issues = self.get_issues(jql_query)
issues = self.get_issues(jql_query, self.ticket_limit)

for issue in issues:
key = issue["key"]

0 comments on commit 59c16f5

Please sign in to comment.