[tracked_attention] Fix the reminder interval (#2200)

This commit is contained in:
Suhaib Mujahid 2023-08-14 11:28:12 -04:00 коммит произвёл GitHub
Родитель 1a69975ab4
Коммит f88559afab
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 24 добавлений и 7 удалений

Просмотреть файл

@ -97,13 +97,19 @@ class TrackedAttention(BzCleaner):
# If we commented before, we want to send reminders when we are close to
# the soft freeze.
is_reminder = bool(last_comment)
if is_reminder and (
self.is_weekend
or not is_no_assignee
or not self.is_soft_freeze_soon
or last_comment["time"] > self.reminder_comment_date
):
return None
if is_reminder:
if self.is_weekend or not is_no_assignee or not self.is_soft_freeze_soon:
return None
# Post reminders based on the configured interval
last_reminder_comment = self._get_last_reminder_comment(bug)
last_comment_time = (
last_reminder_comment["time"]
if last_reminder_comment
else last_comment["time"]
)
if last_comment_time > self.reminder_comment_date:
return None
bugid = str(bug["id"])
@ -280,6 +286,17 @@ class TrackedAttention(BzCleaner):
return None
@staticmethod
def _get_last_reminder_comment(bug: dict) -> Optional[dict]:
"""Get the the last comment generated by this rule"""
for comment in reversed(bug["comments"]):
if comment["author"] == History.BOT and comment["text"].startswith(
"This is a reminder regarding"
):
return comment
return None
if __name__ == "__main__":
TrackedAttention().run()