Skip to content

Commit d003246

Browse files
committed
Improve debug logging in ThrottleMiddleware and update warning message for no_throttle option
1 parent 8a82cfa commit d003246

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

api/ruby/find-inactive-members/find_inactive_members.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ def initialize(app, options = {})
1515
@hour_start_time = Time.now
1616
@last_request_time = Time.now
1717
@mutex = Mutex.new
18-
@debug_enabled = !ENV['THROTTLE_DEBUG'].nil? && !ENV['THROTTLE_DEBUG'].empty?
18+
# Set @debug_enabled to true if the THROTTLE_DEBUG environment variable is set and not empty.
19+
# When enabled, ThrottleMiddleware will output debug information to help diagnose throttling behavior.
20+
# Usage: export THROTTLE_DEBUG=1 @debug_enabled = !ENV['THROTTLE_DEBUG'].nil? && !ENV['THROTTLE_DEBUG'].empty?
1921
@github_rate_limit_remaining = nil
2022
@github_rate_limit_reset = nil
2123
end
@@ -98,8 +100,6 @@ def throttle_request
98100
if time_since_last < required_delay
99101
sleep_time = required_delay - time_since_last
100102
if sleep_time > 0
101-
#delay_reason = @github_rate_limit_remaining ? "dynamic" : "standard"
102-
#$stderr.print "Throttling: waiting #{sleep_time.round(2)}s (#{delay_reason} delay)\n"
103103
sleep(sleep_time)
104104
end
105105
end
@@ -307,7 +307,6 @@ def organization_members
307307
info "Finding #{@organization} members "
308308
members_data = smart_request(:organization_members, @organization)
309309
@members = members_data.collect do |m|
310-
email =
311310
{
312311
login: m["login"],
313312
email: member_email(m[:login]),
@@ -516,9 +515,9 @@ def member_activity
516515
end
517516
end.parse!
518517

519-
# Debug: Check if no_throttle option is set
518+
# Check if no_throttle option is set and warn user
520519
if options[:no_throttle]
521-
puts "DEBUG: no_throttle option is set to: #{options[:no_throttle]}"
520+
puts "WARNING: no_throttle option is set to: #{options[:no_throttle]}"
522521
end
523522

524523
stack = Faraday::RackBuilder.new do |builder|

0 commit comments

Comments
 (0)