• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

moosetechnology / GitProjectHealth / 11498155021

24 Oct 2024 11:15AM UTC coverage: 59.724% (+0.8%) from 58.906%
11498155021

push

github

web-flow
Merge pull request #96 from moosetechnology/develop

Develop

713 of 970 new or added lines in 22 files covered. (73.51%)

15 existing lines in 5 files now uncovered.

9449 of 15821 relevant lines covered (59.72%)

0.6 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

45.3
/src/GitLabHealth-Model-Importer/GLHModelImporter.class.st
1
Class {
2
        #name : #GLHModelImporter,
3
        #superclass : #GPModelImporter,
4
        #instVars : [
5
                'withInitialCommits',
6
                'withInitialMergeRequest',
7
                'generalReader'
8
        ],
9
        #category : #'GitLabHealth-Model-Importer'
10
}
11

12
{ #category : #'private - api' }
13
GLHModelImporter >> addCommits: commitsList toRepository: aProjectRepository [
×
14
        "I take a list of GLHCommit. But some might have been parsed but are already on the model..."
×
15

×
16
        "I return the list of added commits"
×
17

×
18
        | existingCommits newlyFoundCommit |
×
19
        existingCommits := aProjectRepository mooseModel allWithType:
×
20
                                   GLHCommit.
×
21
        newlyFoundCommit := commitsList reject: [ :commitParsed |
×
22
                                    existingCommits anySatisfy: [ :existingCommit |
×
23
                                            existingCommit id = commitParsed id ] ].
×
24
        aProjectRepository mooseModel addAll: newlyFoundCommit.
×
25
        aProjectRepository commits addAll: newlyFoundCommit.
×
26
        ^ newlyFoundCommit
×
27
]
×
28

29
{ #category : #private }
30
GLHModelImporter >> addGroupResultToModel: groupResult [
1✔
31
        |group|
1✔
32
        group := self glhModel add: groupResult unless: self blockOnIdEquality.
1✔
33
        self glhModel
1✔
34
                addAll: group projects
1✔
35
                unless: self blockOnIdEquality.
1✔
36
        ^ group 
1✔
37
]
1✔
38

39
{ #category : #'as yet unclassified' }
40
GLHModelImporter >> chainsCommitsFrom: commitsCollection [
1✔
41

1✔
42
        | dic |
1✔
43
        
1✔
44
        ('Chains ', commitsCollection size printString , ' commits') recordInfo.
1✔
45
        
1✔
46
        dic := ((self glhModel allWithType: GLHCommit) collect: [ :commit |
1✔
47
                        commit id -> commit ]) asSet asDictionary.
1✔
48

1✔
49
        commitsCollection do: [ :commit |
1✔
50
                commit parent_ids do: [ :parentId | 
1✔
51
                        dic
1✔
52
                                at: parentId
1✔
53
                                ifPresent: [ :parentCommit |
1✔
54
                                        parentCommit childCommits
1✔
55
                                                add: commit
1✔
56
                                                unless: self blockOnIdEquality ]
1✔
57
                                ifAbsent: [  ] ] ].
1✔
58
        ^ commitsCollection
1✔
59
]
1✔
60

61
{ #category : #'private - api' }
62
GLHModelImporter >> completeImportProject: aGLHProject [
1✔
63

1✔
64
        | importedProject |
1✔
65
        ('Complete import of project: ' , aGLHProject id printString)
1✔
66
                recordInfo.
1✔
67
        aGLHProject repository ifNotNil: [ ^ aGLHProject ].
1✔
68

1✔
69
        importedProject := self glhModel
1✔
70
                                   add: aGLHProject
1✔
71
                                   unless: self blockOnIdEquality.
1✔
72

1✔
73
        self importPipelinesOfProject: importedProject.
1✔
74

1✔
75
        "aGLHProject creator: (self importUser: aGLHProject creator_id)."
1✔
76

1✔
77
        (self importUser: importedProject creator_id) addCreatedProject:
1✔
78
                importedProject.
1✔
79

1✔
80

1✔
81
        importedProject repository: GLHRepository new.
1✔
82
        self glhModel add: importedProject repository.
1✔
83
        self importRepository: importedProject repository.
1✔
84

1✔
85
        ^ importedProject
1✔
86
]
1✔
87

88
{ #category : #'as yet unclassified' }
89
GLHModelImporter >> completeImportedCommit: aCommit [
1✔
90

1✔
91
        ('completing commit: ' , aCommit short_id printString) recordInfo.
1✔
92
        self importCreatorOfCommit: aCommit.
1✔
93

1✔
94
        self withCommitDiffs ifTrue: [
1✔
95
                | diffs |
1✔
96
                aCommit diffs ifEmpty: [
1✔
97
                        diffs := self importDiffOfCommit: aCommit.
1✔
98
                        self glhModel addAll: diffs unless: self blockForDiffEquality ] ].
1✔
99

1✔
100
        ^ aCommit
1✔
101
]
1✔
102

103
{ #category : #'private - configure reader' }
104
GLHModelImporter >> configureReaderForCommit: reader [
1✔
105

1✔
106
          reader for: GLHCommit do: [ :mapping |
1✔
107
                mapping mapInstVars:
1✔
108
                        #( id short_id title author_name author_email committer_name
1✔
109
                           committer_email message web_url ).
1✔
110
                (mapping mapInstVar: #authored_date) valueSchema: DateAndTime.
1✔
111
                (mapping mapInstVar: #committed_date) valueSchema: DateAndTime.
1✔
112
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
1✔
113
                (mapping mapInstVar: #parent_ids) valueSchema: #ArrayOfIds.
1✔
114
                mapping
1✔
115
                        mapProperty: 'stats'
1✔
116
                        getter: [ :el | "Not used" ]
1✔
117
                        setter: [ :commit :value |
1✔
118
                                commit deletions: (value at: #deletions).
1✔
119
                                commit additions: (value at: #additions) ] ].
1✔
120

1✔
121
        reader for: DateAndTime customDo: [ :mapping |
1✔
122
                mapping decoder: [ :string | DateAndTime fromString: string ] ].
1✔
123

1✔
124
        reader
1✔
125
                for: #ArrayOfIds
1✔
126
                customDo: [ :mapping | mapping decoder: [ :string | string ] ].
1✔
127
  
1✔
128
        reader
1✔
129
                for: #ArrayOfCommit
1✔
130
                customDo: [ :customMappting |
1✔
131
                customMappting listOfElementSchema: GLHCommit ].
1✔
132

1✔
133
]
1✔
134

135
{ #category : #'private - configure reader' }
136
GLHModelImporter >> configureReaderForDiffs: reader [
1✔
137

1✔
138
        reader for: GLHDiff do: [ :mapping |
1✔
139
                mapping mapInstVars:
1✔
140
                        #( deleted_file new_file new_path old_path renamed_file ).
1✔
141
                mapping mapInstVar: #diffString to: #diff ].
1✔
142

1✔
143
        reader
1✔
144
                for: #ArrayOfDiffs
1✔
145
                customDo: [ :customMappting |
1✔
146
                customMappting listOfElementSchema: GLHDiff ].
1✔
147
        ^ reader
1✔
148
]
1✔
149

150
{ #category : #'private - configure reader' }
151
GLHModelImporter >> configureReaderForGroup: reader [
1✔
152

1✔
153
        reader for: GLHGroup do: [ :mapping |
1✔
154
                mapping mapInstVars.
1✔
155
                (mapping mapInstVar: #projects) valueSchema: #ArrayOfProjects ].
1✔
156
        reader mapInstVarsFor: GLHProject.
1✔
157
        reader
1✔
158
                for: #ArrayOfProjects
1✔
159
                customDo: [ :customMappting |
1✔
160
                customMappting listOfElementSchema: GLHProject ].
1✔
161
        reader
1✔
162
                for: #ArrayOfGroups
1✔
163
                customDo: [ :customMappting |
1✔
164
                customMappting listOfElementSchema: GLHGroup ]
1✔
165
]
1✔
166

167
{ #category : #private }
168
GLHModelImporter >> convertApiFileAsFile: aAPIFile [
×
169

×
170
        aAPIFile type = 'tree' ifTrue: [ 
×
171
                ^ GLHFileDirectory new
×
172
                          name: aAPIFile name;
×
173
                          yourself ].
×
174
        ^ GLHFileBlob new
×
175
                  name: aAPIFile name;
×
176
                  yourself
×
177
]
×
178

179
{ #category : #'as yet unclassified' }
180
GLHModelImporter >> detectEntityType: aType overAttribut: aSelector equalTo: value [
1✔
181

1✔
182
        ^ (self glhModel allWithType: aType) detect: [ :entity |
1✔
183
                  (entity perform: aSelector) = value ] ifNone: [ nil ]. 
1✔
184
]
1✔
185

186
{ #category : #accessing }
187
GLHModelImporter >> glhApi [
1✔
188

1✔
189
        self
1✔
190
                deprecated: 'Use #repoApi instead'
1✔
191
                on: '7 October 2024'
1✔
192
                in:
1✔
193
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
1✔
194

1✔
195
        ^ repoApi
1✔
196
]
1✔
197

198
{ #category : #accessing }
199
GLHModelImporter >> glhApi: anObject [
1✔
200

1✔
201
        self
1✔
202
                deprecated: 'Use #repoApi: instead'
1✔
203
                on: '7 October 2024'
1✔
204
                in:
1✔
205
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
1✔
206

1✔
207
        repoApi := anObject
1✔
208
]
1✔
209

210
{ #category : #accessing }
211
GLHModelImporter >> glhModel [
1✔
212

1✔
213
        ^ glhModel
1✔
214
]
1✔
215

216
{ #category : #accessing }
217
GLHModelImporter >> glhModel: anObject [
1✔
218

1✔
219
        glhModel := anObject
1✔
220
]
1✔
221

222
{ #category : #'as yet unclassified' }
223
GLHModelImporter >> importActiveHumanUsers [
×
224

×
225
        | newlyFoundUser page foundUsers |
×
226
        page := 0.
×
227
        foundUsers := OrderedCollection new.
×
228
        newlyFoundUser := { true }.
×
229
        [ newlyFoundUser isNotEmpty ] whileTrue: [
×
230
                | results |
×
231
                page := page + 1.
×
232
                ('import users page ' , page printString) recordInfo.
×
233
                results := self glhApi
×
234
                                   usersHuman: true
×
235
                                   active: true
×
236
                                   withoutProjectBots: true
×
237
                                   perPage: 100
×
238
                                   page: page.
×
239

×
240
                newlyFoundUser := self parseUsersResult: results.
×
241
                "newlyFoundCommit do: [ :c | c repository: aProject repository ]."
×
242

×
243
                foundUsers addAll:
×
244
                        (self glhModel
×
245
                                 addAll: newlyFoundUser
×
246
                                 unless: self blockOnIdEquality) ].
×
247

×
248

×
249
        ^ foundUsers
×
250
]
×
251

252
{ #category : #api }
253
GLHModelImporter >> importAllGroups [
×
254

×
255
        | page foundGroups newlyFoundGroups |
×
256
        page := 0.
×
257
        foundGroups := OrderedCollection new.
×
258
        newlyFoundGroups := { true }.
×
259
        [ newlyFoundGroups isNotEmpty ] whileTrue: [
×
260
                | results |
×
261
                page := page + 1.
×
262
                results := self glhApi listGroupsWithTopLevelOnly: true page: page.
×
263

×
264
                newlyFoundGroups := generalReader
×
265
                                            on: results readStream;
×
266
                                            nextAs: #ArrayOfGroups.
×
267
                foundGroups addAll: newlyFoundGroups ].
×
268
        ^ foundGroups
×
269
]
×
270

271
{ #category : #'as yet unclassified' }
272
GLHModelImporter >> importAndLoadLatestsCommitsOfProject: aGLHProject [
×
273

×
274
        | commits |
×
275
        self completeImportProject: aGLHProject.
×
276
        commits := self importLastestCommitsOfProject: aGLHProject.
×
277
        commits do: [ :commit | self completeImportedCommit: commit ].
×
278
        self chainsCommitsFrom: commits.
×
279
        ^ commits
×
280
]
×
281

282
{ #category : #'private - api' }
283
GLHModelImporter >> importCommit: aCommitID ofProject: aGLHProject [
×
284

×
285
        | result parsedResult |
×
286
        (self glhModel allWithType: GLHCommit) asOrderedCollection
×
287
                detect: [ :commit | commit id = aCommitID ]
×
288
                ifFound: [ :commit | ^ commit ].
×
289
        result := self glhApi
×
290
                          commit: aCommitID
×
291
                          ofProject: aGLHProject id
×
292
                          withStat: true.
×
293
        parsedResult := self parseCommitResult: result.
×
294
        self
×
295
                addCommits: { parsedResult }
×
296
                toRepository: aGLHProject repository.
×
297
        ^ parsedResult
×
298
]
×
299

300
{ #category : #'as yet unclassified' }
301
GLHModelImporter >> importCommitOfProject: anProject withId: anID [
1✔
302

1✔
303
        | commit result |
1✔
304
        anID ifNil: [ ^ nil ].
1✔
305

1✔
306
        ('looking for commit ' , anID printString , ' in project : '
1✔
307
         , anProject id printString) recordInfo.
1✔
308

1✔
309
        commit := (self
1✔
310
                           detectEntityType: GLHCommit
1✔
311
                           overAttribut: #id
1✔
312
                           equalTo: anID) ifNil: [
1✔
313
                          result := self repoApi commit: anID ofProject: anProject id.
1✔
314
                          commit := (self parseCommitsResult: '[' , result , ']')
1✔
315
                                            first.
1✔
316

1✔
317
                          self glhModel add: commit unless: self blockOnIdEquality.
1✔
318
                          commit repository: anProject repository.
1✔
319

1✔
320
                          commit ].
1✔
321

1✔
322
        self withCommitDiffs ifTrue: [ self importDiffOfCommit: commit ].
1✔
323

1✔
324
        ^ commit
1✔
325
]
1✔
326

327
{ #category : #'private - api' }
328
GLHModelImporter >> importCommits: aGLHProject [
×
329
        "limited to the last 20 commits"
×
330

×
331
        | results parsedResults |
×
332
        results := self glhApi
×
333
                           commitsOfProject: aGLHProject id
×
334
                           forRefName: nil
×
335
                           since: nil
×
336
                           until: nil
×
337
                           path: nil
×
338
                           author: nil
×
339
                           all: nil
×
340
                           with_stats: true
×
341
                           firstParent: nil
×
342
                           order: nil
×
343
                           trailers: nil
×
344
                           perPage: nil
×
345
                           page: nil.
×
346
        parsedResults := self parseCommitsResult: results.
×
347
        self glhModel addAll: parsedResults unless: self blockOnIdEquality.
×
348

×
349
        parsedResults do: [ :commit |
×
350
                commit repository: aGLHProject repository ].
×
351

×
352
        self withCommitDiffs ifTrue: [
×
353
                parsedResults do: [ :commit | self importDiffOfCommit: commit ] ].
×
354
        
×
355
        ^ parsedResults. 
×
356
]
×
357

358
{ #category : #'as yet unclassified' }
359
GLHModelImporter >> importCommitsFollowing: aCommit upToDays: aNumberOfDay [
×
360
        "import the 'n' commits of a project starting from an initial 'aCommit' commit. 
×
361
        Lazy import does not import the entities inside the model"
×
362

×
363
        | date |
×
364
        date := aCommit created_at asDateAndTime.
×
365

×
366
        ^ self
×
367
                  importCommitsOfBranch: aCommit branch
×
368
                  forRefName: aCommit branch name
×
369
                  since: date
×
370
                  until: (date + aNumberOfDay day)
×
371
]
×
372

373
{ #category : #commit }
374
GLHModelImporter >> importCommitsOf: aGLHProject withStats: aBoolean until: toDate [
×
375

×
376
        | newlyFoundCommit page |
×
377
        
×
378
        self deprecated: [  ] .
×
379
        
×
380
        page := 0.
×
381
        newlyFoundCommit := { true }.
×
382
        [ newlyFoundCommit isNotEmpty ] whileTrue: [
×
383
                | results parsedResults existingCommits |
×
384
                page := page + 1.
×
385
                ('import commit page ' , page printString) recordInfo.
×
386
                results := self glhApi
×
387
                                   commitsOfProject: aGLHProject id
×
388
                                   forRefName: nil
×
389
                                   since: nil
×
390
                                   until: nil
×
391
                                   path: nil
×
392
                                   author: nil
×
393
                                   all: nil
×
394
                                   with_stats: aBoolean
×
395
                                   firstParent: nil
×
396
                                   order: nil
×
397
                                   trailers: nil
×
398
                                   perPage: 100
×
399
                                   page: page.
×
400
                parsedResults := self parseCommitsResult: results.
×
401
                existingCommits := aGLHProject mooseModel allWithType: GLHCommit.
×
402

×
403
                newlyFoundCommit := parsedResults reject: [ :commitParsed |
×
404
                                            (toDate isNil or: [
×
405
                                                     commitParsed committed_date
×
406
                                                     < toDate asDateAndTime ]) or: [
×
407
                                                    existingCommits anySatisfy: [ :existingCommit |
×
408
                                                            existingCommit id = commitParsed id ] ] ].
×
409
                aGLHProject mooseModel addAll: newlyFoundCommit.
×
410
                aGLHProject repository commits addAll: newlyFoundCommit ].
×
411

×
412

×
413
        self withCommitDiffs ifTrue: [
×
414
                aGLHProject repository commits do: [ :commit |
×
415
                        self importDiffOfCommit: commit ] ]
×
416
]
×
417

418
{ #category : #commit }
419
GLHModelImporter >> importCommitsOfBranch: aGLHBranch forRefName: refName since: fromDate [
×
420

×
421
        ^ self
×
422
                  importCommitsOfBranch: aGLHBranch
×
423
                  forRefName: aGLHBranch name
×
424
                  since: fromDate
×
425
                  until: nil
×
426
]
×
427

428
{ #category : #commit }
429
GLHModelImporter >> importCommitsOfBranch: aGLHBranch forRefName: refName since: fromDate until: toDate [
×
430

×
431
        | newlyFoundCommit page foundCommit|
×
432
        page := 0.
×
433
        foundCommit := OrderedCollection new. 
×
434
        newlyFoundCommit := { true }.
×
435
        [ newlyFoundCommit isNotEmpty ] whileTrue: [
×
436
                | results |
×
437
                page := page + 1.
×
438
                ('import commit page ' , page printString) recordInfo.
×
439
                results := self glhApi
×
440
                                   commitsOfProject: aGLHBranch repository project id
×
441
                                   forRefName: aGLHBranch name
×
442
                                   since:
×
443
                                   (fromDate ifNotNil: [ fromDate asDateAndTime asString ])
×
444
                                   until:
×
445
                                   (toDate ifNotNil: [ toDate asDateAndTime asString ])
×
446
                                   path: nil
×
447
                                   author: nil
×
448
                                   all: nil
×
449
                                   with_stats: nil
×
450
                                   firstParent: nil
×
451
                                   order: nil
×
452
                                   trailers: nil
×
453
                                   perPage: 100
×
454
                                   page: page.
×
455

×
456
                newlyFoundCommit := self parseCommitsResult: results.
×
457
        aGLHBranch commits
×
458
                        addAll: newlyFoundCommit
×
459
                        unless: self blockOnIdEquality.
×
460
        foundCommit addAll: newlyFoundCommit.  
×
461
                        ].
×
462

×
463
        self glhModel
×
464
                addAll: aGLHBranch commits
×
465
                unless: self blockOnIdEquality.
×
466

×
467
        "self withCommitDiffs ifTrue: [
×
468
                aGLHBranch commits: [ :commit | self importDiffOfCommit: commit ] ]."
×
469

×
470
        ^ foundCommit
×
471
]
×
472

473
{ #category : #commit }
474
GLHModelImporter >> importCommitsOfBranch: aGLHBranch forRefName: refName until: toDate [
×
475

×
476
        ^ self
×
477
                  importCommitsOfBranch: aGLHBranch
×
478
                  forRefName: aGLHBranch name
×
479
                  since: nil
×
480
                  until: toDate
×
481
]
×
482

483
{ #category : #commit }
484
GLHModelImporter >> importCommitsOfProject: aProject since: fromDate until: toDate [
1✔
485

1✔
486
        | newlyFoundCommit page foundCommit |
1✔
487
        page := 0.
1✔
488
        foundCommit := OrderedCollection new.
1✔
489
        newlyFoundCommit := { true }.
1✔
490
        [ newlyFoundCommit isNotEmpty ] whileTrue: [
1✔
491
                | results |
1✔
492
                page := page + 1.
1✔
493
                ('import commit page ' , page printString) recordInfo.
1✔
494
                results := self repoApi
1✔
495
                                   commitsOfProject: aProject id
1✔
496
                                   forRefName: nil
1✔
497
                                   since:
1✔
498
                                   (fromDate ifNotNil: [ fromDate asDateAndTime asString ])
1✔
499
                                   until:
1✔
500
                                   (toDate ifNotNil: [ toDate asDateAndTime asString ])
1✔
501
                                   path: nil
1✔
502
                                   author: nil
1✔
503
                                   all: true
1✔
504
                                   with_stats: true
1✔
505
                                   firstParent: nil
1✔
506
                                   order: nil
1✔
507
                                   trailers: nil
1✔
508
                                   perPage: 100
1✔
509
                                   page: page.
1✔
510

1✔
511
                newlyFoundCommit := self parseCommitsResult: results.
1✔
512
                "newlyFoundCommit do: [ :c | c repository: aProject repository ]."
1✔
513

1✔
514
                foundCommit addAll: (aProject repository commits
1✔
515
                        addAll: newlyFoundCommit
1✔
516
                        unless: self blockOnIdEquality). ].
1✔
517

1✔
518

1✔
519
        ^ self glhModel addAll: foundCommit unless: self blockOnIdEquality
1✔
520
]
1✔
521

522
{ #category : #'as yet unclassified' }
523
GLHModelImporter >> importContributedProjectsOfUser: aGLHUser [
×
524

×
525
        | newlyFoundElmts page foundElmts remaningProjects |
×
526
        page := 0.
×
527
        foundElmts := OrderedCollection new.
×
528
        newlyFoundElmts := { true }.
×
529
        [ newlyFoundElmts isNotEmpty ] whileTrue: [
×
530
                | results |
×
531
                page := page + 1.
×
532
                ('import contributed project of user ' , aGLHUser name , ' page '
×
533
                 , page printString) recordInfo.
×
NEW
534
                results := self repoApi
×
535
                                   contributedProjectsOfUserId: aGLHUser id
×
536
                                   orderBy: 'last_activity_at'
×
537
                                   simple: true
×
538
                                   sort: 'desc'
×
539
                                   perPage: 100
×
540
                                   page: page.
×
541

×
542
                newlyFoundElmts := self parseArrayOfProject: results.
×
543

×
544
                foundElmts addAll:
×
545
                        (self glhModel
×
546
                                 addAll: newlyFoundElmts
×
547
                                 unless: self blockOnIdEquality) ].
×
548
        remaningProjects := self importProjects:
×
549
                                    ((foundElmts collect: #id) difference:
×
550
                                             ((self userCatalogue atId: aGLHUser id) at:
×
551
                                                      #contributedProjects)).
×
552

×
553
        aGLHUser contributedProjects
×
554
                addAll: foundElmts , remaningProjects
×
555
                unless: self blockOnIdEquality.
×
556

×
557
        self userCatalogue
×
558
                addUser: aGLHUser
×
559
                withProjects: (aGLHUser contributedProjects collect: #id).
×
560

×
561
        ^ foundElmts
×
562
]
×
563

564
{ #category : #'as yet unclassified' }
565
GLHModelImporter >> importCreatorOfCommit: aCommit [
1✔
566

1✔
567
        aCommit commitCreator ifNil: [                
1✔
568
                aCommit commitCreator:
1✔
569
                        (self importUserByUsername: aCommit author_name) ].
1✔
570
        self userCatalogue addUser: aCommit commitCreator withProject: aCommit repository project id.
1✔
571
        ^ aCommit commitCreator
1✔
572
]
1✔
573

574
{ #category : #api }
575
GLHModelImporter >> importDiffOfCommit: aCommit [
1✔
576

1✔
577
        | result diffsResult |
1✔
578
        aCommit diffs ifNotEmpty: [
1✔
579
                'Diff already importer: ' , aCommit short_id printString recordInfo.
1✔
580
                ^ aCommit diffs ].
1✔
581
        ('Import diff of commit: ' , aCommit short_id printString) recordInfo.
1✔
582
        result := self repoApi
1✔
583
                          commitDiff: aCommit id
1✔
584
                          ofProject: aCommit repository project id
1✔
585
                          unidiff: true.
1✔
586
        (self isServerError: result) ifTrue: [ ^ {  } ].
1✔
587
        diffsResult := self newParseDiffResult: result.
1✔
588

1✔
589
        ^ aCommit diffs addAll: diffsResult unless: self blockForDiffEquality.
1✔
590

1✔
591
]
1✔
592

593
{ #category : #'private - api' }
594
GLHModelImporter >> importDirectoryFiles: aDirectoryFile OfBranch: aBranch [
×
595

×
596
        | result files apiFiles |
×
597
        result := self glhApi
×
598
                          treeOfRepository: aBranch repository project id
×
599
                          ofBranch: aBranch name
×
600
                          andPath: aDirectoryFile path , '/'.
×
601
        apiFiles := self parseFileTreeResult: result.
×
602
        files := apiFiles collect: [ :apiFile |
×
603
                         self convertApiFileAsFile: apiFile ].
×
604
        files do: [ :file |
×
605
                
×
606
                self glhModel add: file.
×
607
                aDirectoryFile addFile: file ].
×
608
        files
×
609
                select: [ :file | file isKindOf: GLHFileDirectory ]
×
610
                thenCollect: [ :file |
×
611
                self importDirectoryFiles: file OfBranch: aBranch ]
×
612
]
×
613

614
{ #category : #'private - api' }
615
GLHModelImporter >> importFilesOfBranch: aBranch [
×
616

×
617
        | result files apiFiles |
×
618
        result := self glhApi
×
619
                          treeOfRepository: aBranch repository project id
×
620
                          ofBranch: aBranch name
×
621
                          andPath: nil.
×
622
        apiFiles := self parseFileTreeResult: result.
×
623
        files := apiFiles collect: [ :apiFile | 
×
624
                         self convertApiFileAsFile: apiFile ].
×
625
        files do: [ :file | 
×
626
                self glhModel add: file.
×
627
                aBranch addFile: file ].
×
628
        files
×
629
                select: [ :file | file isKindOf: GLHFileDirectory ]
×
630
                thenCollect: [ :file | 
×
631
                self importDirectoryFiles: file OfBranch: aBranch ]
×
632
]
×
633

634
{ #category : #api }
635
GLHModelImporter >> importGroup: aGroupID [
1✔
636

1✔
637
        | result groupResult |
1✔
638
        ('Import group: ' , aGroupID printString) recordInfo.
1✔
639

1✔
640
        result := self repoApi group: aGroupID.
1✔
641
        groupResult := self parseGroupResult: result.
1✔
642
        groupResult := self addGroupResultToModel: groupResult.
1✔
643

1✔
644
        groupResult projects do: [ :project |
1✔
645
                self completeImportProject: project ].
1✔
646

1✔
647
        (self subGroupsOf: aGroupID) do: [ :subGroup |
1✔
648
                
1✔
649
                groupResult subGroups
1✔
650
                        add: (self importGroup: subGroup id)
1✔
651
                        unless: self blockOnIdEquality ].
1✔
652
        ^ groupResult
1✔
653
]
1✔
654

655
{ #category : #api }
656
GLHModelImporter >> importJobsOf: aPipeline [
×
657

×
658
        | result jobs |
×
659
        result := self glhApi
×
660
                          jobsOfProject: aPipeline project id
×
661
                          ofPipelines: aPipeline id.
×
662
        jobs := self parseJobsResult: result ofProject: aPipeline project.
×
663
        jobs do: [ :job | aPipeline addJob: job ].
×
664
        self glhModel addAll: jobs
×
665

×
666
]
×
667

668
{ #category : #'private - api' }
669
GLHModelImporter >> importLastestCommitsOfProject: aGLHProject [
1✔
670
        "limited to the last 50 commits"
1✔
671

1✔
672
        | results parsedResults |
1✔
673
        results := self repoApi
1✔
674
                           commitsOfProject: aGLHProject id
1✔
675
                           forRefName: nil
1✔
676
                           since: nil
1✔
677
                           until: nil
1✔
678
                           path: nil
1✔
679
                           author: nil
1✔
680
                           all: true
1✔
681
                           with_stats: true
1✔
682
                           firstParent: nil
1✔
683
                           order: nil
1✔
684
                           trailers: nil
1✔
685
                           perPage: 50
1✔
686
                           page: nil.
1✔
687
        parsedResults := self parseCommitsResult: results.
1✔
688
        parsedResults := self glhModel
1✔
689
                                 addAll: parsedResults
1✔
690
                                 unless: self blockOnIdEquality.
1✔
691

1✔
692
        aGLHProject repository commits
1✔
693
                addAll: parsedResults
1✔
694
                unless: self blockOnIdEquality.
1✔
695
        "parsedResults do: [ :commit |
1✔
696
                commit repository: aGLHProject repository ]."
1✔
697

1✔
698
        self withCommitDiffs ifTrue: [
1✔
699
                parsedResults do: [ :commit | self importDiffOfCommit: commit ] ].
1✔
700

1✔
701
        ^ parsedResults
1✔
702
]
1✔
703

704
{ #category : #commit }
705
GLHModelImporter >> importParentCommitsOfCommit: aGLHCommit since: aDate [
×
706

×
707
        | parentsIds commits |
×
708
        commits := OrderedCollection new.
×
709
        aGLHCommit created_at asDateAndTime < aDate asDateAndTime ifTrue: [
×
710
                 
×
711
                ^ commits
×
712
                          add: aGLHCommit;
×
713
                          yourself ].
×
714

×
715
        parentsIds := aGLHCommit parent_ids.
×
716

×
717
        commits addAll: (parentsIds collect: [ :id |
×
718
                         self
×
719
                                 importCommitOfProject: aGLHCommit repository project
×
720
                                 withId: id ]).
×
721

×
722

×
723
        ^ (commits collect: [ :parentCommit |
×
724
                   self importParentCommitsOfCommit: parentCommit since: aDate ])
×
725
                  flatten
×
726
]
×
727

728
{ #category : #'private - api' }
729
GLHModelImporter >> importPipelinesOfProject: aGLHProject [
1✔
730

1✔
731
        (self pipelinesOf: aGLHProject id) do: [ :pipeline |
1✔
732
                self glhModel add: pipeline unless: self blockOnIdEquality .
1✔
733
                aGLHProject pipelines add: pipeline unless: self blockOnIdEquality]
1✔
734
]
1✔
735

736
{ #category : #projects }
737
GLHModelImporter >> importProject: aProjectID [
×
738

×
739
        | result projectResult |
×
740
        ('Import project with id: ' , aProjectID printString) recordInfo.
×
741

×
742
        result := self glhApi project: aProjectID.
×
743
        projectResult := self parseProjectResult: result.
×
744

×
745
        ^ self completeImportProject: projectResult
×
746
]
×
747

748
{ #category : #imports }
749
GLHModelImporter >> importProjects [
×
750

×
751
        ^ self importProjectsSince: nil
×
752
]
×
753

754
{ #category : #projects }
755
GLHModelImporter >> importProjects: aCollectionOfProjectID [
×
756

×
757
        ^ aCollectionOfProjectID collect: [ :id | self importProject: id ]
×
758
]
×
759

760
{ #category : #imports }
761
GLHModelImporter >> importProjectsSince: since [
×
762
        "heavy import of all projects"
×
763

×
764
        "copy import from commits"
×
765

×
766
        | newlyFoundProjects page foundProject amount |
×
767
        ('import all Projects since: ' , since printString) recordInfo.
×
768

×
769
        "number of projects per page"
×
770
        amount := 100.
×
771
        page := 0.
×
772
        foundProject := OrderedCollection new.
×
773
        newlyFoundProjects := { true }.
×
774
        [ newlyFoundProjects isNotEmpty ] whileTrue: [
×
775
                | results |
×
776
                page := page + 1.
×
777
                ('import projects page #' , page printString) recordInfo.
×
778

×
779
                results := self glhApi projects: amount since: since page: page.
×
780

×
781
                newlyFoundProjects := self glhModel
×
782
                                              addAll: (self parseArrayOfProject: results)
×
783
                                              unless: self blockOnIdEquality.
×
784
                foundProject addAll: newlyFoundProjects ].
×
785

×
786
        ^ foundProject
×
787
]
×
788

789
{ #category : #'private - api' }
790
GLHModelImporter >> importRepository: aGLHRepository [
1✔
791

1✔
792
        | resultBranches branches |
1✔
793
        [
1✔
794
        ('import the repository of project ' , aGLHRepository project name)
1✔
795
                recordInfo.
1✔
796

1✔
797
        resultBranches := self repoApi branchesOfRepository:
1✔
798
                                  aGLHRepository project id.
1✔
799
        branches := self parseBranchesResult: resultBranches.
1✔
800

1✔
801
        'import the branches of project ' recordInfo.
1✔
802

1✔
803
        branches := aGLHRepository branches
1✔
804
                            addAll: branches
1✔
805
                            unless: self blockOnNameEquality.
1✔
806
        branches := self glhModel
1✔
807
                            addAll: branches
1✔
808
                            unless: self blockOnNameEquality.
1✔
809

1✔
810

1✔
811
        self withFiles ifTrue: [
1✔
812
                branches do: [ :branch | self importFilesOfBranch: branch ] ] ]
1✔
813
                on: NeoJSONParseError
1✔
814
                do: [
1✔
815
                self inform: aGLHRepository project name , ' has no repository' ]
1✔
816
]
1✔
817

818
{ #category : #'private - api' }
819
GLHModelImporter >> importUser: aUserID [
1✔
820

1✔
821
        | result userResult |
1✔
822
        (self glhModel allWithType: GLHUser)
1✔
823
                detect: [ :user | user id = aUserID ]
1✔
824
                ifFound: [ :user | ^ user ].
1✔
825
        ('Import user: ' , aUserID printString) recordInfo.
1✔
826
        result := self repoApi user: aUserID.
1✔
827
        userResult := self parseUserResult: result.
1✔
828
        ^ self glhModel add: userResult unless: self blockOnIdEquality
1✔
829
]
1✔
830

831
{ #category : #user }
832
GLHModelImporter >> importUserByUsername: anUsername [
1✔
833

1✔
834
        | dicUsername resultUser |
1✔
835
        dicUsername := ((self glhModel allWithType: GLHUser) collect: [ :user |
1✔
836
                                user username -> user ]) asSet asDictionary.
1✔
837

1✔
838
        dicUsername addAll: self userCatalogue collectUsernames.
1✔
839

1✔
840

1✔
841
        resultUser := dicUsername
1✔
842
                              at: anUsername
1✔
843
                              ifAbsent: [ "thus we have to import this new user"
1✔
844
                                      | result userId searchResult |
1✔
845
                                      ('Import user with username: '
1✔
846
                                       , anUsername printString) recordInfo.
1✔
847
                                      result := self repoApi usersSearchByUsername:
1✔
848
                                                        anUsername.
1✔
849
                                      searchResult := NeoJSONReader fromString: result.
1✔
850

1✔
851
                                      (searchResult class = Dictionary and: [
1✔
852
                                               (searchResult at: #message) includesSubstring:
1✔
853
                                                       '403 Forbidden' ])
1✔
854
                                              ifTrue: [ "if the result is an 403 error we fake a new user"
1✔
855
                                                      self glhModel
1✔
856
                                                              add: (GLHUser new
1✔
857
                                                                               username: anUsername;
1✔
858
                                                                               name: anUsername;
1✔
859
                                                                               yourself)
1✔
860
                                                              unless: [ :nu :ou | nu username = ou username ] ]
1✔
861
                                              ifFalse: [
1✔
862
                                                      searchResult
1✔
863
                                                              ifEmpty: [ "results can be empty thus we force a new user with the info we have "
1✔
864
                                                                      self glhModel
1✔
865
                                                                              add: (GLHUser new
1✔
866
                                                                                               username: anUsername;
1✔
867
                                                                                               name: anUsername;
1✔
868
                                                                                               yourself)
1✔
869
                                                                              unless: [ :nu :ou | nu username = ou username ] ]
1✔
870
                                                              ifNotEmpty: [ "because we may already have the researched user, we look by ID in the model"
1✔
871
                                                                      userId := searchResult first at: #id.
1✔
872
                                                                      (self glhModel allWithType: GLHUser)
1✔
873
                                                                              detect: [ :user | user id = userId ]
1✔
874
                                                                              ifNone: [ self importUser: userId ] ] ] ].
1✔
875

1✔
876
        self userCatalogue addUser: resultUser withName: anUsername.
1✔
877

1✔
878
        ^ resultUser
1✔
879
]
1✔
880

881
{ #category : #initialization }
882
GLHModelImporter >> initReader [
1✔
883

1✔
884
        generalReader := NeoJSONReader new.
1✔
885
        self configureReaderForCommit: generalReader.
1✔
886
        self configureReaderForGroup: generalReader.
1✔
887
        self configureReaderForDiffs: generalReader. 
1✔
888
]
1✔
889

890
{ #category : #initialization }
891
GLHModelImporter >> initialize [
1✔
892

1✔
893
        super initialize.
1✔
894
        withCommitDiffs := false.
1✔
895
        withInitialCommits := false.
1✔
896
        withInitialMergeRequest := false.
1✔
897

1✔
898
        withCommitsSince := (Date today - 1 week) asDateAndTime.
1✔
899

1✔
900
        self initReader.
1✔
901

1✔
902
]
1✔
903

904
{ #category : #api }
905
GLHModelImporter >> isServerError: aString [
1✔
906
        ^ aString = '{"message":"500 Internal Server Error"}'
1✔
907
]
1✔
908

909
{ #category : #importer }
910
GLHModelImporter >> loadAllProjectsFromRepositorySoftware [
×
911
        "heavy import that load all the active project inside the model. Only import the project entities"
×
912
        |projects|
×
913
        
×
914
        projects := self glhApi projects. 
×
915
]
×
916

917
{ #category : #private }
918
GLHModelImporter >> newParseCommitResult: result [
×
919

×
920
        generalReader  on: result readStream.
×
921

×
922
        ^ generalReader nextAs: GLHCommit
×
923
]
×
924

925
{ #category : #private }
926
GLHModelImporter >> newParseDiffResult: result [
1✔
927

1✔
928
        generalReader on: result readStream.
1✔
929
        ^ generalReader nextAs: #ArrayOfDiffs
1✔
930
]
1✔
931

932
{ #category : #parsing }
933
GLHModelImporter >> parseArrayOfProject: arrayOfProjects [
×
934

×
935
        | reader |
×
936
        reader := NeoJSONReader on: arrayOfProjects readStream.
×
937
        reader
×
938
                for: #ArrayOfProjects
×
939
                customDo: [ :customMappting |
×
940
                customMappting listOfElementSchema: GLHProject ].
×
941
        reader for: GLHProject do: [ :mapping |
×
942
                mapping mapInstVar: #name to: #name.
×
943
                mapping mapInstVar: #description to: #description.
×
944
                mapping mapInstVar: #id to: #id.
×
945
                mapping mapInstVar: #archived to: #archived.
×
946
                mapping mapInstVar: #web_url to: #html_url.
×
947
                mapping mapInstVar: #topics to: #topics ].
×
948
        ^ reader nextAs: #ArrayOfProjects
×
949
]
×
950

951
{ #category : #private }
952
GLHModelImporter >> parseBranchesResult: result [
1✔
953

1✔
954
        | reader |
1✔
955
        reader := NeoJSONReader on: result readStream.
1✔
956
        reader mapInstVarsFor: GLHBranch.
1✔
957
        reader
1✔
958
                for: #ArrayOfBranch
1✔
959
                customDo: [ :customMappting | 
1✔
960
                customMappting listOfElementSchema: GLHBranch ].
1✔
961
        ^ reader nextAs: #ArrayOfBranch
1✔
962
]
1✔
963

964
{ #category : #private }
965
GLHModelImporter >> parseCommitResult: result [
×
966

×
967
        | reader |
×
968
        reader := NeoJSONReader on: result readStream.
×
969

×
970
        reader for: GLHCommit do: [ :mapping |
×
971
                mapping mapInstVars:
×
972
                        #( id short_id title author_name author_email committer_name
×
973
                           committer_email message web_url ).
×
974
                (mapping mapInstVar: #authored_date) valueSchema: DateAndTime.
×
975
                (mapping mapInstVar: #committed_date) valueSchema: DateAndTime.
×
976
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
×
977
                (mapping mapInstVar: #parent_ids) valueSchema: #ArrayOfIds.
×
978
                mapping
×
979
                        mapProperty: 'stats'
×
980
                        getter: [ :el | "Not used" ]
×
981
                        setter: [ :commit :value |
×
982
                                commit deletions: (value at: #deletions).
×
983
                                commit additions: (value at: #additions) ] ].
×
984

×
985
        reader for: DateAndTime customDo: [ :mapping |
×
986
                mapping decoder: [ :string | DateAndTime fromString: string ] ].
×
987

×
988
        reader
×
989
                for: #ArrayOfIds
×
990
                customDo: [ :mapping | mapping decoder: [ :string | string ] ].
×
991

×
992

×
993
        ^ reader nextAs: GLHCommit
×
994
]
×
995

996
{ #category : #private }
997
GLHModelImporter >> parseCommitsResult: result [
1✔
998

1✔
999
        | reader |
1✔
1000
        reader := NeoJSONReader on: result readStream.
1✔
1001

1✔
1002
          reader for: GLHCommit do: [ :mapping |
1✔
1003
                mapping mapInstVars:
1✔
1004
                        #( id short_id title author_name author_email committer_name
1✔
1005
                           committer_email message web_url ).
1✔
1006
                (mapping mapInstVar: #authored_date) valueSchema: DateAndTime.
1✔
1007
                (mapping mapInstVar: #committed_date) valueSchema: DateAndTime.
1✔
1008
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
1✔
1009
                (mapping mapInstVar: #parent_ids) valueSchema: #ArrayOfIds.
1✔
1010
                mapping
1✔
1011
                        mapProperty: 'stats'
1✔
1012
                        getter: [ :el | "Not used" ]
1✔
1013
                        setter: [ :commit :value |
1✔
1014
                                commit deletions: (value at: #deletions).
1✔
1015
                                commit additions: (value at: #additions) ] ].
1✔
1016

1✔
1017
        reader for: DateAndTime customDo: [ :mapping |
1✔
1018
                mapping decoder: [ :string | DateAndTime fromString: string ] ].
1✔
1019

1✔
1020
        reader
1✔
1021
                for: #ArrayOfIds
1✔
1022
                customDo: [ :mapping | mapping decoder: [ :string | string ] ].
1✔
1023
  
1✔
1024
        reader
1✔
1025
                for: #ArrayOfCommit
1✔
1026
                customDo: [ :customMappting |
1✔
1027
                customMappting listOfElementSchema: GLHCommit ].
1✔
1028

1✔
1029
        ^ reader nextAs: #ArrayOfCommit
1✔
1030
]
1✔
1031

1032
{ #category : #private }
1033
GLHModelImporter >> parseDiffResult: result [
×
1034

×
1035
        | reader |
×
1036
        self
×
1037
                deprecated: 'Use #newParseDiffResult: instead'
×
1038
                on: '28 June 2024'
×
1039
                in:
×
1040
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
×
1041
        reader := NeoJSONReader on: result readStream.
×
1042
        reader for: GLHDiff do: [ :mapping |
×
1043
                mapping mapInstVars:
×
1044
                        #( deleted_file new_file new_path old_path renamed_file ).
×
1045
                mapping mapInstVar: #diffString to: #diff ].
×
1046

×
1047
        reader
×
1048
                for: #ArrayOfDiffs
×
1049
                customDo: [ :customMappting |
×
1050
                customMappting listOfElementSchema: GLHDiff ].
×
1051
        ^ reader nextAs: #ArrayOfDiffs
×
1052
]
×
1053

1054
{ #category : #private }
1055
GLHModelImporter >> parseFileTreeResult: aResult [
×
1056

×
1057
        | reader |
×
1058
        reader := NeoJSONReader on: aResult readStream.
×
1059
        reader mapInstVarsFor: GLHApiFile.
×
1060
        reader
×
1061
                for: #ArrayOfFile
×
1062
                customDo: [ :customMappting | 
×
1063
                customMappting listOfElementSchema: GLHApiFile ].
×
1064
        ^ reader nextAs: #ArrayOfFile
×
1065
]
×
1066

1067
{ #category : #private }
1068
GLHModelImporter >> parseGroupResult: aResult [
1✔
1069

1✔
1070
        | reader |
1✔
1071

1✔
1072
        reader := NeoJSONReader on: aResult readStream.
1✔
1073
        reader for: GLHGroup do: [ :mapping |
1✔
1074
                mapping mapInstVars.
1✔
1075
                (mapping mapInstVar: #projects) valueSchema: #ArrayOfProjects ].
1✔
1076
        reader mapInstVarsFor: GLHProject.
1✔
1077
        reader
1✔
1078
                for: #ArrayOfProjects
1✔
1079
                customDo: [ :customMappting |
1✔
1080
                customMappting listOfElementSchema: GLHProject ].
1✔
1081
        ^ reader nextAs: GLHGroup
1✔
1082
]
1✔
1083

1084
{ #category : #private }
1085
GLHModelImporter >> parseJobsResult: result ofProject: aProject [
×
1086

×
1087
        | reader |
×
1088
        reader := NeoJSONReader on: result readStream.
×
1089
        reader for: GLHJob do: [ :mapping |
×
1090
                mapping mapInstVars: #( id allow_failure web_url name ).
×
1091

×
1092
                mapping
×
1093
                        mapProperty: #user
×
1094
                        getter: [ :object | #ignore ]
×
1095
                        setter: [ :object :value |
×
1096
                        object user: (self importUser: (value at: #id)) ].
×
1097

×
1098
                mapping
×
1099
                        mapProperty: #commit
×
1100
                        getter: [ :object | #ignore ]
×
1101
                        setter: [ :object :value |
×
1102
                                value ifNotNil: [
×
1103
                                        object commit:
×
1104
                                                (self importCommit: (value at: #id) ofProject: aProject) ] ].
×
1105

×
1106
                mapping
×
1107
                        mapProperty: #duration
×
1108
                        getter: [ :object | #ignore ]
×
1109
                        setter: [ :object :value |
×
1110
                        value ifNotNil: [ object duration: value seconds ] ] ].
×
1111

×
1112
        reader
×
1113
                for: #ArrayOfGLHJob
×
1114
                customDo: [ :customMappting |
×
1115
                customMappting listOfElementSchema: GLHJob ].
×
1116
        ^ reader nextAs: #ArrayOfGLHJob
×
1117
]
×
1118

1119
{ #category : #private }
1120
GLHModelImporter >> parsePipelinesResult: result [
1✔
1121

1✔
1122
        | reader |
1✔
1123
        
1✔
1124
        (result includesSubstring: '{"message":"40' )ifTrue: [ ^ {  } ].
1✔
1125
        
1✔
1126
        reader := NeoJSONReader on: result readStream.
1✔
1127
        reader mapInstVarsFor: GLHPipeline.
1✔
1128
        reader for: GLHPipeline do: [ :mapping |
1✔
1129
                mapping
1✔
1130
                        mapProperty: #created_at
1✔
1131
                        getter: [ :object | #ignore ]
1✔
1132
                        setter: [ :object :value |
1✔
1133
                        object runDate: (DateAndTime fromString: value) ] ].
1✔
1134
        reader
1✔
1135
                for: #ArrayOfPipelines
1✔
1136
                customDo: [ :customMappting |
1✔
1137
                customMappting listOfElementSchema: GLHPipeline ].
1✔
1138
        ^ reader nextAs: #ArrayOfPipelines
1✔
1139
]
1✔
1140

1141
{ #category : #parsing }
1142
GLHModelImporter >> parseProjectResult: aResult [ 
×
1143
                | reader |
×
1144
        reader := NeoJSONReader on: aResult readStream.
×
1145
        reader for: GLHProject do: [ :mapping |
×
1146
                mapping mapInstVars. ].
×
1147
"        reader mapInstVarsFor: GLHProject."
×
1148

×
1149
        ^ reader nextAs: GLHProject
×
1150
]
×
1151

×
1152
{ #category : #private }
×
1153
GLHModelImporter >> parseSubGroupResult: aResult [
×
1154

×
1155
        | reader |
×
1156
        reader := NeoJSONReader on: aResult readStream.
×
1157
        self configureReaderForGroup: reader.
×
1158
        ^ reader nextAs: #ArrayOfGroups
×
1159
]
×
1160

×
1161
{ #category : #private }
×
1162
GLHModelImporter >> parseUserResult: result [
×
1163

×
1164
        | reader |
×
1165
        reader := NeoJSONReader on: result readStream.
×
1166
        reader mapInstVarsFor: GLHUser.
×
1167
        ^ reader nextAs: GLHUser
×
1168
]
×
1169

×
1170
{ #category : #private }
×
1171
GLHModelImporter >> parseUsersResult: result [
×
1172

×
1173
        | reader |
×
1174
        reader := NeoJSONReader on: result readStream.
×
1175

×
1176
        reader mapInstVarsFor: GLHUser.
×
1177

×
1178
        reader
×
1179
                for: #ArrayOfUser
×
1180
                customDo: [ :customMappting |
×
1181
                customMappting listOfElementSchema: GLHUser ].
×
1182

×
1183
        ^ reader nextAs: #ArrayOfUser
×
1184
]
×
1185

×
1186
{ #category : #'private - api' }
×
1187
GLHModelImporter >> pipelinesOf: aProjectID [
×
1188

×
1189
        | result |
×
1190
        ('Search pipelines of: ' , aProjectID printString) recordInfo.
×
NEW
1191
        result := self repoApi pipelinesOfProject: aProjectID.
×
1192
        ^ self parsePipelinesResult: result .
×
1193
]
×
1194

×
1195
{ #category : #'as yet unclassified' }
×
1196
GLHModelImporter >> selectEntityType: aType overAttribut: aSelector equalTo: value [
×
1197

×
1198
        ^ (self glhModel allWithType: aType)
×
1199
                select: [ :entity | (entity perform: aSelector) = value ]
×
1200
]
×
1201

×
1202
{ #category : #'private - api' }
×
1203
GLHModelImporter >> subGroupsOf: aGroupID [
×
1204

×
1205
        | results parsedResult result page |
×
1206
        ('Search subgroup of: ' , aGroupID printString) recordInfo.
×
1207
        results := OrderedCollection new.
×
1208
        page := 0.
×
1209
        
×
1210
        parsedResult := { true }.
×
1211
        [ parsedResult size > 0 ] whileTrue: [ 
×
NEW
1212
                result := self repoApi subgroupsOfGroup: aGroupID page: page.
×
1213
                parsedResult := self parseSubGroupResult: result.
×
1214
                results addAll: parsedResult.
×
1215
                                page := page + 1. ].
×
1216
        
×
1217
        ^ results
×
1218
]
×
1219

×
1220
{ #category : #accessing }
×
1221
GLHModelImporter >> withInitialCommits: boolean [
×
1222
        withInitialCommits := boolean 
×
1223
]
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc