Skip to content

Commit 3e66902

Browse files
authored
Teach ServicingPipeline to paginate project board items (#18328)
Oops, it didn't support more than 100 items!
1 parent a3a4464 commit 3e66902

File tree

1 file changed

+42
-31
lines changed

1 file changed

+42
-31
lines changed

tools/ReleaseEngineering/ServicingPipeline.ps1

+42-31
Original file line numberDiff line numberDiff line change
@@ -105,48 +105,59 @@ Function Get-GraphQlProjectNumberGivenName($Organization, $Name) {
105105

106106
Function Get-GraphQlProjectWithNodes($Organization, $Number) {
107107
# It's terrible, but it pulls *all* of the info we need all at once!
108-
$Project = Invoke-GitHubGraphQlApi -Query '
109-
query($organization: String! $number: Int!) {
110-
organization(login: $organization) {
111-
projectV2(number: $number) {
112-
id
113-
number
114-
title
115-
fields(first:20){
116-
nodes {
117-
... on ProjectV2FieldCommon { id name }
118-
... on ProjectV2SingleSelectField { options { id name } }
119-
}
120-
}
121-
items {
122-
nodes {
123-
id
124-
status: fieldValueByName(name: "Status") {
125-
... on ProjectV2ItemFieldSingleSelectValue { name }
108+
$cursor = ""
109+
$hasMore = $true
110+
$nodes = @()
111+
While ($hasMore) {
112+
$Project = Invoke-GitHubGraphQlApi -Query '
113+
query($organization: String!, $number: Int!, $after: String) {
114+
organization(login: $organization) {
115+
projectV2(number: $number) {
116+
id
117+
number
118+
title
119+
fields(first:20){
120+
nodes {
121+
... on ProjectV2FieldCommon { id name }
122+
... on ProjectV2SingleSelectField { options { id name } }
126123
}
127-
content {
128-
... on Issue {
129-
number
130-
closedByPullRequestsReferences(first: 8) {
131-
... on PullRequestConnection {
132-
nodes {
133-
number
134-
mergeCommit { oid }
124+
}
125+
items(first: 100, after: $after) {
126+
pageInfo { hasNextPage endCursor }
127+
nodes {
128+
id
129+
status: fieldValueByName(name: "Status") {
130+
... on ProjectV2ItemFieldSingleSelectValue { name }
131+
}
132+
content {
133+
... on Issue {
134+
number
135+
closedByPullRequestsReferences(first: 8) {
136+
... on PullRequestConnection {
137+
nodes {
138+
number
139+
mergeCommit { oid }
140+
}
135141
}
136142
}
137143
}
138-
}
139-
... on PullRequest {
140-
number
141-
mergeCommit { oid }
144+
... on PullRequest {
145+
number
146+
mergeCommit { oid }
147+
}
142148
}
143149
}
144150
}
145151
}
146152
}
147153
}
154+
' -Variables @{ organization = $Organization; number = $Number; after = $cursor }
155+
156+
$n += $Project.organization.projectV2.items.nodes
157+
$cursor = $Project.organization.projectV2.items.pageInfo.endCursor
158+
$hasMore = $Project.organization.projectV2.items.pageInfo.hasNextPage
148159
}
149-
' -Variables @{ organization = $Organization; number = $Number }
160+
$Project.organization.projectV2.items.nodes = $n
150161
$Project
151162
}
152163

0 commit comments

Comments
 (0)