1515)
1616DAYS_BEFORE_REMINDER = 30
1717DAYS_BEFORE_CLOSE = 30
18+ REMINDER_COOLDOWN_DAYS = 7 # Don't post another reminder within 7 days
1819
1920def main ():
2021 g = Github (os .environ ['GH_TOKEN' ])
@@ -27,7 +28,6 @@ def main():
2728 now = datetime .datetime .utcnow ()
2829
2930 for issue in issues :
30- # comments = list(issue.get_comments())
3131 print (f"[VALIDATION] Would fetch comments for issue/PR #{ issue .number } ." )
3232 comments = [] # Replace with mock comments if needed
3333 last_comment = comments [- 1 ] if comments else None
@@ -36,33 +36,37 @@ def main():
3636 auto_comments = [c for c in comments if REMINDER_MARKER in c .body ]
3737 user_comments = [c for c in comments if REMINDER_MARKER not in c .body ]
3838
39- # Case 1: No automation comment yet, and last comment > 30 days ago
39+ # ---- REMINDER LOGIC ----
40+ # Only remind if NO reminder in last 7 days
41+ recent_auto_reminder = any (
42+ (now - c .created_at ).days < REMINDER_COOLDOWN_DAYS
43+ for c in auto_comments
44+ )
45+
4046 if not auto_comments :
4147 if last_comment and (now - last_comment .created_at ).days >= DAYS_BEFORE_REMINDER :
42- # Tag the issue author or PR author
4348 user = issue .user .login
44- # issue.create_comment(REMINDER_COMMENT.format(user))
4549 print (f"[VALIDATION] Would remind { user } on issue/PR #{ issue .number } " )
4650
47- # Case 2: Automation comment exists, but no user response after 30 more days
48- elif auto_comments :
51+ elif auto_comments and not recent_auto_reminder :
52+ # Only post new reminder if last was > REMINDER_COOLDOWN_DAYS ago
53+ last_auto = auto_comments [- 1 ]
54+ user = issue .user .login
55+ if (now - last_auto .created_at ).days >= REMINDER_COOLDOWN_DAYS :
56+ print (f"[VALIDATION] Would remind { user } again on issue/PR #{ issue .number } " )
57+
58+ # ---- EXISTING CLOSE/REMOVE LABEL LOGIC ----
59+ if auto_comments :
4960 last_auto = auto_comments [- 1 ]
50- # Any user response after automation?
5161 user_responded = any (
5262 c .created_at > last_auto .created_at and c .user .login == issue .user .login
5363 for c in user_comments
5464 )
55-
5665 if not user_responded :
5766 if (now - last_auto .created_at ).days >= DAYS_BEFORE_CLOSE :
58- # issue.create_comment(CLOSE_COMMENT)
59- # issue.edit(state="closed")
6067 print (f"[VALIDATION] Would close issue/PR #{ issue .number } due to inactivity." )
61-
6268 else :
63- # Remove label if user responded
6469 labels = [l .name for l in issue .labels if l .name != LABEL ]
65- # issue.set_labels(*labels)
6670 print (f"[VALIDATION] Would remove label from issue/PR #{ issue .number } after user response." )
6771
6872if __name__ == "__main__" :
0 commit comments