From c4560df605956ac1d48eedaecfa9192030853f05 Mon Sep 17 00:00:00 2001 From: sunny Date: Wed, 22 Apr 2026 08:11:46 +0000 Subject: [PATCH] Adding loop counter in check issue closure for denial --- main.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index c04bc14..8d1916b 100644 --- a/main.go +++ b/main.go @@ -51,6 +51,7 @@ func handleInterrupt(ctx context.Context, client *github.Client, apprv *approval func newCommentLoopChannel(ctx context.Context, apprv *approvalEnvironment, client *github.Client, pollingInterval time.Duration) chan int { channel := make(chan int) go func() { + loop_ctr := 0 for { comments, _, err := client.Issues.ListComments(ctx, apprv.targetRepoOwner, apprv.targetRepoName, apprv.approvalIssueNumber, &github.IssueListCommentsOptions{}) if err != nil { @@ -118,9 +119,16 @@ func newCommentLoopChannel(ctx context.Context, apprv *approvalEnvironment, clie } channel <- 1 close(channel) - return + return case approvalStatusPending: if apprv.closeIssueMeansDenial { + // Loop counter to make an API call only once per 10 interation, intention: avoid github rate limiting and reduce api cost and stress. + if loop_ctr < 10 { + loop_ctr += 1 + continue + } + loop_ctr = 0 + issue, _, err := client.Issues.Get( ctx,