Browse Source

chore(gh-comments): Drop pr window to 7 days for rollout (#51837)

Based on an ask from product
Aniket Das 1 year ago
parent
commit
5a63ff00ea
2 changed files with 3 additions and 2 deletions
  1. 2 1
      src/sentry/tasks/commit_context.py
  2. 1 1
      tests/sentry/tasks/test_commit_context.py

+ 2 - 1
src/sentry/tasks/commit_context.py

@@ -36,6 +36,7 @@ DEBOUNCE_CACHE_KEY = lambda group_id: f"process-commit-context-{group_id}"
 DEBOUNCE_PR_COMMENT_CACHE_KEY = lambda pullrequest_id: f"pr-comment-{pullrequest_id}"
 DEBOUNCE_PR_COMMENT_LOCK_KEY = lambda pullrequest_id: f"queue_comment_task:{pullrequest_id}"
 PR_COMMENT_TASK_TTL = timedelta(minutes=5).total_seconds()
+PR_COMMENT_WINDOW = 7  # days
 
 logger = logging.getLogger(__name__)
 
@@ -83,7 +84,7 @@ def queue_comment_task_if_needed(
         return
 
     pr = pr_query.get()
-    if pr.date_added >= datetime.now(tz=timezone.utc) - timedelta(days=30) and (
+    if pr.date_added >= datetime.now(tz=timezone.utc) - timedelta(days=PR_COMMENT_WINDOW) and (
         not pr.pullrequestcomment_set.exists()
         or group_owner.group_id not in pr.pullrequestcomment_set.get().group_ids
     ):

+ 1 - 1
tests/sentry/tasks/test_commit_context.py

@@ -614,7 +614,7 @@ class TestGHCommentQueuing(IntegrationTestCase, TestCommitContextMixin):
     @responses.activate
     def test_gh_comment_pr_too_old(self, get_jwt, mock_comment_workflow):
         """No comment on pr that's older than 30 days"""
-        self.pull_request.date_added = iso_format(before_now(days=31))
+        self.pull_request.date_added = iso_format(before_now(days=8))
         self.pull_request.save()
 
         self.add_responses()