@@ -79,12 +79,18 @@ def to_csv
79
79
end
80
80
81
81
class GithubProjectItemCollection < GithubQuery
82
+ PAGINATION_BATCH_SIZE = 100
83
+
82
84
def self . find_by ( project_id :)
83
- execute ( "
85
+ execute_paginated ( "
84
86
query{
85
87
node(id: \" #{ project_id } \" ) {
86
88
... on ProjectV2 {
87
- items(first: 100) {
89
+ items(first: ALL) {
90
+ pageInfo {
91
+ endCursor
92
+ hasNextPage
93
+ }
88
94
nodes {
89
95
id
90
96
content{
@@ -174,6 +180,27 @@ def self.find_by(project_id:)
174
180
" )
175
181
end
176
182
183
+ def self . execute_paginated ( query )
184
+ github_project_item_collection = nil
185
+ all_nodes = [ ]
186
+ pagination_string = "first: #{ PAGINATION_BATCH_SIZE } "
187
+
188
+ loop do
189
+ github_project_item_collection = page = execute ( query . gsub ( "first: ALL" , pagination_string ) )
190
+ all_nodes += page . result . dig ( "data" , "node" , "items" , "nodes" )
191
+
192
+ if page . result . dig ( "data" , "node" , "items" , "pageInfo" , "hasNextPage" )
193
+ last_cursor_id = page . result . dig ( "data" , "node" , "items" , "pageInfo" , "endCursor" )
194
+ pagination_string = "first: #{ PAGINATION_BATCH_SIZE } , after: \" #{ last_cursor_id } \" "
195
+ else
196
+ break
197
+ end
198
+ end
199
+
200
+ github_project_item_collection . result [ "data" ] [ "node" ] [ "items" ] [ "nodes" ] = all_nodes
201
+ github_project_item_collection
202
+ end
203
+
177
204
def items
178
205
result . dig ( "data" , "node" , "items" , "nodes" ) . collect do |node_data |
179
206
github_project_item = GithubProjectItem . new
0 commit comments