Skip to content

Commit 07f8966

Browse files
committed
Iterate over results until we don't get a nextPageToken
1 parent 46a5711 commit 07f8966

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

src/google.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,21 @@ export async function getAdminService() {
2626

2727
export async function getGithubUsersFromGoogle(): Promise<Set<string>> {
2828
const service = await mod.getAdminService()
29+
let githubAccounts = new Set<string>()
30+
let nextPageToken = null
2931

30-
const userList = await service.users.list({
31-
customer: 'my_customer',
32-
maxResults: 250,
33-
projection: 'custom',
34-
fields: 'users(customSchemas/Accounts/github(value))',
35-
customFieldMask: 'Accounts',
36-
})
37-
38-
const githubAccounts = mod.formatUserList(userList.data.users)
32+
do {
33+
const userList = await service.users.list({
34+
customer: 'my_customer',
35+
maxResults: 250,
36+
projection: 'custom',
37+
nextPageToken: nextPageToken,
38+
fields: 'users(customSchemas/Accounts/github(value)),nextPageToken',
39+
customFieldMask: 'Accounts',
40+
})
41+
nextPageToken = userList.data.nextPageToken
42+
githubAccounts = new Set([...githubAccounts, ...formatUserList(userList.data.users)])
43+
} while (nextPageToken != null)
3944
return githubAccounts
4045
}
4146

0 commit comments

Comments
 (0)