@@ -152,32 +152,41 @@ func (c *UserListConfig) Load() error {
152152 } `graphql:"enterprise(slug: $slug)"`
153153 }
154154
155+ window := 100
155156 variables := map [string ]interface {}{
156157 "slug" : githubv4 .String ("prodyna" ),
157- "first" : githubv4 .Int (100 ),
158+ "first" : githubv4 .Int (window ),
158159 "after" : (* githubv4 .String )(nil ),
159160 }
160161
161- err := client .Query (ctx , & query , variables )
162- if err != nil {
163- slog .ErrorContext (ctx , "Unable to query" , "error" , err )
164- }
162+ for offset := 0 ; ; offset += window {
163+ err := client .Query (ctx , & query , variables )
164+ if err != nil {
165+ slog .ErrorContext (ctx , "Unable to query" , "error" , err )
166+ }
165167
166- c .userList .Enterprise = Enterprise {
167- Slug : query .Enterprise .Slug ,
168- Name : query .Enterprise .Name ,
169- }
168+ c .userList .Enterprise = Enterprise {
169+ Slug : query .Enterprise .Slug ,
170+ Name : query .Enterprise .Name ,
171+ }
170172
171- for i , e := range query .Enterprise .OwnerInfo .SamlIdentityProvider .ExternalIdentities .Edges {
172- u := User {
173- Number : i + 1 ,
174- Login : e .Node .User .Login ,
175- Email : e .Node .SamlIdentity .NameId ,
173+ for i , e := range query .Enterprise .OwnerInfo .SamlIdentityProvider .ExternalIdentities .Edges {
174+ u := User {
175+ Number : offset + i + 1 ,
176+ Login : e .Node .User .Login ,
177+ Email : e .Node .SamlIdentity .NameId ,
178+ }
179+ for _ , o := range e .Node .User .Organizations .Nodes {
180+ u .Organizations = append (u .Organizations , Organization {Name : o .Name })
181+ }
182+ c .userList .Users = append (c .userList .Users , u )
176183 }
177- for _ , o := range e .Node .User .Organizations .Nodes {
178- u .Organizations = append (u .Organizations , Organization {Name : o .Name })
184+
185+ if ! query .Enterprise .OwnerInfo .SamlIdentityProvider .ExternalIdentities .PageInfo .HasNextPage {
186+ break
179187 }
180- c .userList .Users = append (c .userList .Users , u )
188+
189+ variables ["after" ] = githubv4 .NewString (query .Enterprise .OwnerInfo .SamlIdentityProvider .ExternalIdentities .PageInfo .EndCursor )
181190 }
182191
183192 slog .InfoContext (ctx , "Loaded userlist" , "users" , len (c .userList .Users ))
0 commit comments