Skip to content
Permalink
Browse files
[hotfix] move config parsing into FlinkJiraRule class
  • Loading branch information
knaufk committed Apr 22, 2021
1 parent aa8c557 commit 836ee7d377f7b44a11e0bde9a8231de538772210
Showing 5 changed files with 17 additions and 28 deletions.
@@ -62,16 +62,18 @@ def get_args():
password=os.environ["JIRA_PASSWORD"],
)

stale_assigned_rule = StaleAssignedRule(jira, jira_bot_config, args.dryrun)
stale_minor_rule = StaleMinorRule(jira, jira_bot_config, args.dryrun)
stale_assigned_rule = StaleAssignedRule(
jira, jira_bot_config["stale_assigned"], args.dryrun
)
stale_minor_rule = StaleMinorRule(jira, jira_bot_config["stale_minor"], args.dryrun)
stale_major_rule = StaleMajorOrAboveRule(
jira, jira_bot_config, args.dryrun, "Major"
jira, jira_bot_config["stale_major"], args.dryrun, "Major"
)
stale_critical_rule = StaleMajorOrAboveRule(
jira, jira_bot_config, args.dryrun, "Critical"
jira, jira_bot_config["stale_critical"], args.dryrun, "Critical"
)
stale_blocker_rule = StaleMajorOrAboveRule(
jira, jira_bot_config, args.dryrun, "Blocker"
jira, jira_bot_config["stale_blocker"], args.dryrun, "Blocker"
)
stale_assigned_rule.run()
stale_minor_rule.run()
@@ -25,8 +25,13 @@ class FlinkJiraRule:

def __init__(self, jira_client, config, is_dry_run):
self.jira_client = jira_client
self.config = config
self.is_dry_run = is_dry_run
self.stale_days = config["stale_days"].get()
self.warning_days = config["warning_days"].get()
self.warning_label = config["warning_label"].get()
self.done_label = config["done_label"].get()
self.done_comment = config["done_comment"].get()
self.warning_comment = config["warning_comment"].get()

def get_issues(self, jql_query):
"""Queries the JIRA PI for all issues that match the given JQL Query
@@ -30,12 +30,6 @@ class StaleAssignedRule(FlinkJiraRule):

def __init__(self, jira_client, config, is_dry_run):
super().__init__(jira_client, config, is_dry_run)
self.stale_days = config["stale_assigned"]["stale_days"].get()
self.warning_days = config["stale_assigned"]["warning_days"].get()
self.warning_label = config["stale_assigned"]["warning_label"].get()
self.done_label = config["stale_assigned"]["done_label"].get()
self.done_comment = config["stale_assigned"]["done_comment"].get()
self.warning_comment = config["stale_assigned"]["warning_comment"].get()

def run(self):
self.unassign_tickets_marked_stale()
@@ -33,14 +33,6 @@ class StaleMajorOrAboveRule(FlinkJiraRule):

def __init__(self, jira_client, config, is_dry_run, priority):
super().__init__(jira_client, config, is_dry_run)
self.stale_days = config[f"stale_{priority.lower()}"]["stale_days"].get()
self.warning_days = config[f"stale_{priority.lower()}"]["warning_days"].get()
self.warning_label = config[f"stale_{priority.lower()}"]["warning_label"].get()
self.done_label = config[f"stale_{priority.lower()}"]["done_label"].get()
self.done_comment = config[f"stale_{priority.lower()}"]["done_comment"].get()
self.warning_comment = config[f"stale_{priority.lower()}"][
"warning_comment"
].get()
self.priority = priority

LOWER_PRIORITIES = {"Blocker": "Critical", "Critical": "Major", "Major": "Minor"}
@@ -78,8 +70,10 @@ def close_tickets_marked_stale(self):

def mark_stale_tickets_stale(self):

stale_tickets = f"project=FLINK AND priority = {self.priority} AND resolution = Unresolved AND assignee is " \
f"empty AND updated < startOfDay(-{self.stale_days}d)"
stale_tickets = (
f"project=FLINK AND priority = {self.priority} AND resolution = Unresolved AND assignee is "
f"empty AND updated < startOfDay(-{self.stale_days}d)"
)
logging.info(f"Looking for {self.priority} tickets, which are stale.")
issues = self.get_issues(stale_tickets)

@@ -30,12 +30,6 @@ class StaleMinorRule(FlinkJiraRule):

def __init__(self, jira_client, config, is_dry_run):
super().__init__(jira_client, config, is_dry_run)
self.stale_days = config["stale_minor"]["stale_days"].get()
self.warning_days = config["stale_minor"]["warning_days"].get()
self.warning_label = config["stale_minor"]["warning_label"].get()
self.done_label = config["stale_minor"]["done_label"].get()
self.done_comment = config["stale_minor"]["done_comment"].get()
self.warning_comment = config["stale_minor"]["warning_comment"].get()

def run(self):
self.close_tickets_marked_stale()

0 comments on commit 836ee7d

Please sign in to comment.