@@ -32,7 +32,12 @@ type UserList struct {
32
32
Updated string `json:"updated"`
33
33
Enterprise Enterprise `json:"enterprise"`
34
34
Users []* User `json:"users"`
35
- Warnings []string `json:"warnings"`
35
+ Warnings []* Warning `json:"warnings"`
36
+ }
37
+
38
+ type Warning struct {
39
+ Message string `json:"message"`
40
+ Last bool `json:"last"`
36
41
}
37
42
38
43
type Enterprise struct {
@@ -55,10 +60,12 @@ type Organization struct {
55
60
Login string `json:"login"`
56
61
Name string `json:"name"`
57
62
Repositories * []Repository `json:"repositories"`
63
+ Last bool `json:"last"`
58
64
}
59
65
60
66
type Repository struct {
61
67
Name string `json:"name"`
68
+ Last bool `json:"last"`
62
69
}
63
70
64
71
func (c * UserListConfig ) Validate () error {
@@ -174,6 +181,12 @@ func (ul *UserList) upsertUser(user User) {
174
181
}
175
182
}
176
183
slog .Info ("Upserting user" , "login" , user .Login )
184
+ // mark all eixsting users as last = false
185
+ for i , _ := range ul .Users {
186
+ ul .Users [i ].Last = false
187
+ }
188
+ // mark the new user as last = true
189
+ user .Last = true
177
190
ul .Users = append (ul .Users , & user )
178
191
}
179
192
@@ -209,6 +222,13 @@ func (u *User) upsertOrganization(org Organization) {
209
222
return
210
223
}
211
224
}
225
+ slog .Debug ("Upserting organization" , "name" , org .Name )
226
+ // mark all existing organizations as last = false
227
+ for i , _ := range * u .Organizations {
228
+ (* u .Organizations )[i ].Last = false
229
+ }
230
+ // mark the new organization as last = true
231
+ org .Last = true
212
232
* u .Organizations = append (* u .Organizations , org )
213
233
}
214
234
@@ -220,6 +240,12 @@ func (o *Organization) upsertRepository(repo Repository) {
220
240
}
221
241
}
222
242
slog .Debug ("Upserting repository" , "name" , repo .Name , "organization" , o .Name )
243
+ // mark all existing repositories as last = false
244
+ for i := range * o .Repositories {
245
+ (* o .Repositories )[i ].Last = false
246
+ }
247
+ // mark the new repository as last = true
248
+ repo .Last = true
223
249
* o .Repositories = append (* o .Repositories , repo )
224
250
}
225
251
@@ -237,6 +263,7 @@ func (u *User) createOrganization(login string, name string) *Organization {
237
263
Login : login ,
238
264
Name : name ,
239
265
Repositories : new ([]Repository ),
266
+ Last : false ,
240
267
}
241
268
u .upsertOrganization (* org )
242
269
return org
@@ -261,7 +288,11 @@ func (o *Organization) createRepository(name string) *Repository {
261
288
262
289
func (c * UserList ) addWarning (warning string ) {
263
290
if c .Warnings == nil {
264
- c .Warnings = make ([]string , 0 )
291
+ c .Warnings = make ([]* Warning , 0 )
292
+ }
293
+ // mark all exisint warnings as last = false
294
+ for _ , w := range c .Warnings {
295
+ w .Last = false
265
296
}
266
- c .Warnings = append (c .Warnings , warning )
297
+ c .Warnings = append (c .Warnings , & Warning { Message : warning , Last : true } )
267
298
}
0 commit comments