Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include link to wiki in the second slo action #52

Merged
merged 1 commit into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions backlogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# Icons used for PASS or FAIL in the md file
result_icons = {"pass": "💚", "fail": "🔴"}
reminder_text = "This ticket was set to **{priority}** priority but was not updated [within the SLO period]({url}). Please consider picking up this ticket or just set the ticket to the next lower priority."
update_slo_text = "The ticket will be set to the next lower priority **{priority}**."
reminder_regex = (
r"^This ticket was set to .* priority but was not updated.* Please consider"
)
Expand Down Expand Up @@ -78,6 +79,9 @@ def json_rest(method, url, rest=None):

def issue_reminder(conf, poo, poo_reminder_state):
priority = poo["priority"]["name"]
msg = reminder_text.format(priority=priority, url=data["url"])
if "comment" in conf:
msg = conf["comment"]
if data["reminder-comment-on-issues"]:
journals = retrieve_journals(poo)
if journals is None:
Expand All @@ -89,33 +93,30 @@ def issue_reminder(conf, poo, poo_reminder_state):
if priority == "Low" and poo_reminder_state['has_repeat_reminder']:
print("Skipping priority update for {}, already at lowest".format(poo["id"]))
return
_update_issue_priority(poo["id"], priority, poo_reminder_state)
_update_issue_priority(poo["id"], priority, poo_reminder_state, msg)
return
_send_first_reminder(poo["id"], priority, conf)
_send_first_reminder(poo["id"], msg)


def _send_first_reminder(poo_id, priority_current, conf):
msg = reminder_text.format(priority=priority_current, url=data["url"])
if "comment" in conf:
msg = conf["comment"]
def _send_first_reminder(poo_id, msg):
print("Writing reminder for {}".format(poo_id))
url = "{}/{}.json".format(data["web"], poo_id)
json_rest("PUT", url, {"issue": {"notes": msg}})


def _update_issue_priority(poo_id, priority_current, poo_reminder_state):
def _update_issue_priority(poo_id, priority_current, poo_reminder_state, msg):
if poo_reminder_state['has_repeat_reminder'] and (poo_reminder_state['last_reminder'] + slo_priorities[priority_current]["period"]) < present:

msg = "No response to reminder. Reducing priority from {} to next lower {} for {}"
print(msg.format(priority_current,
note = "No response to reminder. Reducing priority from {} to next lower {} for {}"
print(note.format(priority_current,
slo_priorities[priority_current]["next_priority"]["name"],
poo_id))
url = "{}/{}.json".format(data["web"], poo_id)
msg = " ".join(update_slo_text.format(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I execute this I think it's not what we want :D

>>> update_slo_text = "The ticket will be set to the next lower priority **{priority}**."
>>> msg = " ".join(update_slo_text.format(priority=23))
>>> msg
'T h e   t i c k e t   w i l l   b e   s e t   t o   t h e   n e x t   l o w e r   p r i o r i t y   * * 2 3 * * .'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And @b10n1k please see if you can add test coverage - since I mistakenly thought this was covered, which is why I thought it must still work

priority=slo_priorities[priority_current]["next_priority"]["name"]))
json_rest("PUT", url,
{"issue":
{"priority_id": slo_priorities[priority_current]["next_priority"]["id"],
"notes": "The ticket will be set to the next lower priority {}".format(
slo_priorities[priority_current]["next_priority"]["name"])}})
"notes": msg}})


def list_issues(conf, root):
Expand Down Expand Up @@ -146,7 +147,8 @@ def reminder_exists(poo, journals, state):
if journal.get("notes", None) is None or len(journal["notes"]) == 0:
continue
if re.search(reminder_regex, journal["notes"]):
state['last_reminder'] = datetime.strptime(journal["created_on"], "%Y-%m-%dT%H:%M:%SZ")
state['last_reminder'] = datetime.strptime(journal["created_on"],
"%Y-%m-%dT%H:%M:%SZ")
state['has_repeat_reminder'] = True
return True
state['has_repeat_reminder'] = False
Expand Down
4 changes: 3 additions & 1 deletion tests/test_comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,13 @@ def test_automatic_priority_on_issue(self):
["Urgent", "High", 6, 25],
["High", "Normal", 5, 35],
["Normal", "Low", 4, 700]]
expected_str = "Reducing priority from {} to next lower {} for 1000"
for params in test_params:
with self.subTest(params):
self._set_mock_data(params)
out, err = self.capsys.readouterr()
assert re.search("Reducing priority from {} to next lower {} for 1000".format(params[0],params[1]), out)
assert re.search(expected_str.format(params[0],
params[1]), out)


def test_issue_with_low_priority_never_change(self):
Expand Down