@@ -183,14 +183,44 @@ def info(message)
183
183
$stdout. print message
184
184
end
185
185
186
+ # Helper method to manually paginate requests with proper throttling
187
+ def paginated_request ( method , *args , **kwargs )
188
+ results = [ ]
189
+ page = 1
190
+ per_page = 100
191
+
192
+ loop do
193
+ # Merge pagination parameters with existing kwargs
194
+ page_kwargs = kwargs . merge ( page : page , per_page : per_page )
195
+
196
+ # Handle different method signatures
197
+ if args . empty?
198
+ response = @client . send ( method , page_kwargs )
199
+ else
200
+ response = @client . send ( method , *args , page_kwargs )
201
+ end
202
+
203
+ break if response . empty?
204
+
205
+ results . concat ( response )
206
+ page += 1
207
+
208
+ # Break if we got less than a full page (indicates last page)
209
+ break if response . length < per_page
210
+ end
211
+
212
+ results
213
+ end
214
+
186
215
def member_email ( login )
187
216
@email ? @client . user ( login ) [ :email ] : ""
188
217
end
189
218
190
219
def organization_members
191
220
# get all organization members and place into an array of hashes
192
221
info "Finding #{ @organization } members "
193
- @members = @client . organization_members ( @organization ) . collect do |m |
222
+ members_data = paginated_request ( :organization_members , @organization )
223
+ @members = members_data . collect do |m |
194
224
email =
195
225
{
196
226
login : m [ "login" ] ,
@@ -204,7 +234,8 @@ def organization_members
204
234
def organization_repositories
205
235
info "Gathering a list of repositories..."
206
236
# get all repos in the organizaton and place into a hash
207
- @repositories = @client . organization_repositories ( @organization ) . collect do |repo |
237
+ repos_data = paginated_request ( :organization_repositories , @organization )
238
+ @repositories = repos_data . collect do |repo |
208
239
repo [ "full_name" ]
209
240
end
210
241
info "#{ @repositories . length } repositories discovered\n "
@@ -224,7 +255,8 @@ def commit_activity(repo)
224
255
# get all commits after specified date and iterate
225
256
info "...commits"
226
257
begin
227
- @client . commits_since ( repo , @date ) . each do |commit |
258
+ commits = paginated_request ( :commits_since , repo , @date )
259
+ commits . each do |commit |
228
260
# if commmitter is a member of the org and not active, make active
229
261
if commit [ "author" ] . nil?
230
262
add_unrecognized_author ( commit [ :commit ] [ :author ] )
@@ -246,7 +278,8 @@ def issue_activity(repo, date=@date)
246
278
# get all issues after specified date and iterate
247
279
info "...Issues"
248
280
begin
249
- @client . list_issues ( repo , { :since => date } ) . each do |issue |
281
+ issues = paginated_request ( :list_issues , repo , since : date )
282
+ issues . each do |issue |
250
283
# if there's no user (ghost user?) then skip this // THIS NEEDS BETTER VALIDATION
251
284
if issue [ "user" ] . nil?
252
285
next
@@ -266,7 +299,8 @@ def issue_comment_activity(repo, date=@date)
266
299
# get all issue comments after specified date and iterate
267
300
info "...Issue comments"
268
301
begin
269
- @client . issues_comments ( repo , { :since => date } ) . each do |comment |
302
+ comments = paginated_request ( :issues_comments , repo , since : date )
303
+ comments . each do |comment |
270
304
# if there's no user (ghost user?) then skip this // THIS NEEDS BETTER VALIDATION
271
305
if comment [ "user" ] . nil?
272
306
next
@@ -285,7 +319,8 @@ def issue_comment_activity(repo, date=@date)
285
319
def pr_activity ( repo , date = @date )
286
320
# get all pull request comments comments after specified date and iterate
287
321
info "...Pull Request comments"
288
- @client . pull_requests_comments ( repo , { :since => date } ) . each do |comment |
322
+ comments = paginated_request ( :pull_requests_comments , repo , since : date )
323
+ comments . each do |comment |
289
324
# if there's no user (ghost user?) then skip this // THIS NEEDS BETTER VALIDATION
290
325
if comment [ "user" ] . nil?
291
326
next
@@ -401,7 +436,7 @@ def member_activity
401
436
end
402
437
403
438
Octokit . configure do |kit |
404
- kit . auto_paginate = true
439
+ kit . auto_paginate = false # Disable auto-pagination to ensure throttling on each request
405
440
kit . middleware = stack
406
441
end
407
442
0 commit comments