@@ -133,6 +133,14 @@ class InactiveMemberSearch
133133
134134 def initialize ( options = { } )
135135 @client = options [ :client ]
136+ @options = options # Store options for later use
137+
138+ # Warn if throttling is disabled
139+ if options [ :no_throttle ]
140+ $stderr. print "⚠️ WARNING: API throttling is DISABLED! This may cause rate limit errors.\n "
141+ $stderr. print "🚨 Use this option only for testing or with GitHub Enterprise instances with higher limits.\n \n "
142+ end
143+
136144 if options [ :check ]
137145 check_app
138146 check_scopes
@@ -269,6 +277,23 @@ def paginated_request(method, *args, **kwargs)
269277 results
270278 end
271279
280+ # Smart request method that uses auto-pagination when throttling is disabled
281+ def smart_request ( method , *args , **kwargs )
282+ if @options [ :no_throttle ]
283+ # Use auto-pagination (simpler, faster, but no throttling)
284+ retry_on_403 ( "fetching #{ method } " ) do
285+ if args . empty?
286+ @client . send ( method , kwargs )
287+ else
288+ @client . send ( method , *args , kwargs )
289+ end
290+ end
291+ else
292+ # Use manual pagination with throttling
293+ paginated_request ( method , *args , **kwargs )
294+ end
295+ end
296+
272297 def member_email ( login )
273298 return "" unless @email
274299
@@ -280,7 +305,7 @@ def member_email(login)
280305 def organization_members
281306 # get all organization members and place into an array of hashes
282307 info "Finding #{ @organization } members "
283- members_data = paginated_request ( :organization_members , @organization )
308+ members_data = smart_request ( :organization_members , @organization )
284309 @members = members_data . collect do |m |
285310 email =
286311 {
@@ -295,7 +320,7 @@ def organization_members
295320 def organization_repositories
296321 info "Gathering a list of repositories..."
297322 # get all repos in the organizaton and place into a hash
298- repos_data = paginated_request ( :organization_repositories , @organization )
323+ repos_data = smart_request ( :organization_repositories , @organization )
299324 @repositories = repos_data . collect do |repo |
300325 repo [ "full_name" ]
301326 end
@@ -316,7 +341,7 @@ def commit_activity(repo)
316341 # get all commits after specified date and iterate
317342 info "...commits"
318343 begin
319- commits = paginated_request ( :commits_since , repo , @date )
344+ commits = smart_request ( :commits_since , repo , @date )
320345 commits . each do |commit |
321346 # if commmitter is a member of the org and not active, make active
322347 if commit [ "author" ] . nil?
@@ -339,7 +364,7 @@ def issue_activity(repo, date=@date)
339364 # get all issues after specified date and iterate
340365 info "...Issues"
341366 begin
342- issues = paginated_request ( :list_issues , repo , since : date )
367+ issues = smart_request ( :list_issues , repo , since : date )
343368 issues . each do |issue |
344369 # if there's no user (ghost user?) then skip this // THIS NEEDS BETTER VALIDATION
345370 if issue [ "user" ] . nil?
@@ -360,7 +385,7 @@ def issue_comment_activity(repo, date=@date)
360385 # get all issue comments after specified date and iterate
361386 info "...Issue comments"
362387 begin
363- comments = paginated_request ( :issues_comments , repo , since : date )
388+ comments = smart_request ( :issues_comments , repo , since : date )
364389 comments . each do |comment |
365390 # if there's no user (ghost user?) then skip this // THIS NEEDS BETTER VALIDATION
366391 if comment [ "user" ] . nil?
@@ -380,7 +405,7 @@ def issue_comment_activity(repo, date=@date)
380405 def pr_activity ( repo , date = @date )
381406 # get all pull request comments comments after specified date and iterate
382407 info "...Pull Request comments"
383- comments = paginated_request ( :pull_requests_comments , repo , since : date )
408+ comments = smart_request ( :pull_requests_comments , repo , since : date )
384409 comments . each do |comment |
385410 # if there's no user (ghost user?) then skip this // THIS NEEDS BETTER VALIDATION
386411 if comment [ "user" ] . nil?
@@ -481,23 +506,34 @@ def member_activity
481506 options [ :verbose ] = v
482507 end
483508
509+ opts . on ( '-t' , '--no-throttle' , "Disable API request throttling (use with caution)" ) do |t |
510+ puts "DEBUG: -t flag was triggered, t value = #{ t . inspect } "
511+ options [ :no_throttle ] = true
512+ end
513+
484514 opts . on ( '-h' , '--help' , "Display this help" ) do |h |
485515 puts opts
486516 exit 0
487517 end
488518end . parse!
489519
520+ # Debug: Check if no_throttle option is set
521+ if options [ :no_throttle ]
522+ puts "DEBUG: no_throttle option is set to: #{ options [ :no_throttle ] } "
523+ end
524+
490525stack = Faraday ::RackBuilder . new do |builder |
491- builder . use ThrottleMiddleware
526+ builder . use ThrottleMiddleware unless options [ :no_throttle ]
492527 builder . use Octokit ::Middleware ::FollowRedirects
493528 builder . use Octokit ::Response ::RaiseError
494529 builder . use Octokit ::Response ::FeedParser
495530 builder . response :logger if @debug
496531 builder . adapter Faraday . default_adapter
497532end
498533
534+ # Conditionally enable auto-pagination when throttling is disabled
499535Octokit . configure do |kit |
500- kit . auto_paginate = false # Disable auto-pagination to ensure throttling on each request
536+ kit . auto_paginate = options [ :no_throttle ] ? true : false
501537 kit . middleware = stack
502538end
503539
0 commit comments