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

moosetechnology / GitProjectHealth / 10880023292

16 Sep 2024 08:17AM UTC coverage: 20.538%. First build
10880023292

push

github

web-flow
Update GLHModelImporter.class.st

1 of 2 new or added lines in 1 file covered. (50.0%)

1961 of 9548 relevant lines covered (20.54%)

0.21 hits per line

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

30.78
/src/GitLabHealth-Model-Importer/GLHModelImporter.class.st
1
Class {
2
        #name : 'GLHModelImporter',
3
        #superclass : 'GPModelImporter',
4
        #instVars : [
5
                'glhApi',
6
                'withCommitDiffs',
7
                'withInitialCommits',
8
                'withInitialMergeRequest',
9
                'generalReader',
10
                'userCatalogue'
11
        ],
12
        #classVars : [
13
                'currentImporter'
14
        ],
15
        #category : 'GitLabHealth-Model-Importer'
16
}
17

18
{ #category : 'accessing' }
19
GLHModelImporter class >> current [
×
20

×
21
        ^ currentImporter
×
22
]
×
23

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

×
28
        "I return the list of added commits"
×
29

×
30
        | existingCommits newlyFoundCommit |
×
31
        existingCommits := aProjectRepository mooseModel allWithType:
×
32
                                   GLHCommit.
×
33
        newlyFoundCommit := commitsList reject: [ :commitParsed |
×
34
                                    existingCommits anySatisfy: [ :existingCommit |
×
35
                                            existingCommit id = commitParsed id ] ].
×
36
        aProjectRepository mooseModel addAll: newlyFoundCommit.
×
37
        aProjectRepository commits addAll: newlyFoundCommit.
×
38
        ^ newlyFoundCommit
×
39
]
×
40

41
{ #category : 'private' }
42
GLHModelImporter >> addGroupResultToModel: groupResult [
1✔
43
        |group|
1✔
44
        group := self glhModel add: groupResult unless: self blockOnIdEquality.
1✔
45
        self glhModel
1✔
46
                addAll: group projects
1✔
47
                unless: self blockOnIdEquality.
1✔
48
        ^ group 
1✔
49
]
1✔
50

51
{ #category : 'as yet unclassified' }
52
GLHModelImporter >> blockEqualityOn: aSymbol [
1✔
53
        ^ [ :existing :new |
1✔
54
          (existing perform: aSymbol) = (new perform: aSymbol) ]
1✔
55
]
1✔
56

57
{ #category : 'equality' }
58
GLHModelImporter >> blockForDiffEquality [
1✔
59
        ^ [ :existing :new |
1✔
60
                        existing diffString size = new diffString size and: [
1✔
61
                                existing diffString = new diffString ] ]
1✔
62
]
1✔
63

64
{ #category : 'equality' }
65
GLHModelImporter >> blockOnIdEquality [
1✔
66

1✔
67
        ^ [ :existing :new |
1✔
68
          existing id = new id ]
1✔
69
]
1✔
70

71
{ #category : 'equality' }
72
GLHModelImporter >> blockOnNameEquality [
1✔
73

1✔
74
        ^ self blockEqualityOn: #name
1✔
75
]
1✔
76

77
GLHModelImporter >> chainsCommitsFrom: commitsCollection [
×
78

×
79
        | dic |
×
80
        
×
81
        ('Chains ', commitsCollection size printString , ' commits') recordInfo.
×
82
        
×
83
        dic := ((self glhModel allWithType: GLHCommit) collect: [ :commit |
×
84
                        commit id -> commit ]) asSet asDictionary.
×
85

×
86
        commitsCollection do: [ :commit |
×
87
                commit parent_ids do: [ :parentId | 
×
88
                        dic
×
89
                                at: parentId
×
90
                                ifPresent: [ :parentCommit |
×
91
                                        parentCommit childCommits
×
92
                                                add: commit
×
93
                                                unless: self blockOnIdEquality ]
×
94
                                ifAbsent: [  ] ] ].
×
95
        ^ commitsCollection
×
96
]
×
97

98

99
{ #category : 'private - api' }
100
GLHModelImporter >> completeImportProject: aGLHProject [
1✔
101

1✔
102
        | importedProject |
1✔
103
        ('Complete import of project: ' , aGLHProject id printString)
1✔
104
                recordInfo.
1✔
105
        aGLHProject repository ifNotNil: [ ^ aGLHProject ].
1✔
106

1✔
107
        importedProject := self glhModel
1✔
108
                                   add: aGLHProject
1✔
109
                                   unless: self blockOnIdEquality.
1✔
110

1✔
111
        self importPipelinesOfProject: importedProject.
1✔
112

1✔
113
        "aGLHProject creator: (self importUser: aGLHProject creator_id)."
1✔
114

1✔
115
        (self importUser: importedProject creator_id) addCreatedProject:
1✔
116
                importedProject.
1✔
117

1✔
118

1✔
119
        importedProject repository: GLHRepository new.
1✔
120
        self glhModel add: importedProject repository.
1✔
121
        self importRepository: importedProject repository.
1✔
122

1✔
123
        ^ importedProject
1✔
124
]
1✔
125

126
{ #category : 'as yet unclassified' }
127
GLHModelImporter >> completeImportedCommit: aCommit [
×
128

×
129
        ('completing commit: ' , aCommit short_id printString) recordInfo.
×
130
        self importCreatorOfCommit: aCommit.
×
131

×
132
        self withCommitDiffs ifTrue: [
×
133
                | diffs |
×
134
                aCommit diffs ifEmpty: [
×
135
                        diffs := self importDiffOfCommit: aCommit.
×
136
                        self glhModel addAll: diffs unless: self blockForDiffEquality ] ].
×
137

×
138
        ^ aCommit
×
139
]
×
140

141

142
{ #category : #'private - configure reader' }
143
GLHModelImporter >> configureReaderForCommit: reader [
1✔
144

1✔
145
          reader for: GLHCommit do: [ :mapping |
1✔
146
                mapping mapInstVars:
1✔
147
                        #( id short_id title author_name author_email committer_name
1✔
148
                           committer_email message web_url ).
1✔
149
                (mapping mapInstVar: #authored_date) valueSchema: DateAndTime.
1✔
150
                (mapping mapInstVar: #committed_date) valueSchema: DateAndTime.
1✔
151
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
1✔
152
                (mapping mapInstVar: #parent_ids) valueSchema: #ArrayOfIds.
1✔
153
                mapping
1✔
154
                        mapProperty: 'stats'
1✔
155
                        getter: [ :el | "Not used" ]
1✔
156
                        setter: [ :commit :value |
1✔
157
                                commit deletions: (value at: #deletions).
1✔
158
                                commit additions: (value at: #additions) ] ].
1✔
159

1✔
160
        reader for: DateAndTime customDo: [ :mapping |
1✔
161
                mapping decoder: [ :string | DateAndTime fromString: string ] ].
1✔
162

1✔
163
        reader
1✔
164
                for: #ArrayOfIds
1✔
165
                customDo: [ :mapping | mapping decoder: [ :string | string ] ].
1✔
166
  
1✔
167
        reader
1✔
168
                for: #ArrayOfCommit
1✔
169
                customDo: [ :customMappting |
1✔
170
                customMappting listOfElementSchema: GLHCommit ].
1✔
171

1✔
172
]
1✔
173

174

175
{ #category : #'private - configure reader' }
176
GLHModelImporter >> configureReaderForDiffs: reader [
1✔
177

1✔
178
        reader for: GLHDiff do: [ :mapping |
1✔
179
                mapping mapInstVars:
1✔
180
                        #( deleted_file new_file new_path old_path renamed_file ).
1✔
181
                mapping mapInstVar: #diffString to: #diff ].
1✔
182

1✔
183
        reader
1✔
184
                for: #ArrayOfDiffs
1✔
185
                customDo: [ :customMappting |
1✔
186
                customMappting listOfElementSchema: GLHDiff ].
1✔
187
        ^ reader
1✔
188
]
1✔
189

190

191
{ #category : #'private - configure reader' }
192
GLHModelImporter >> configureReaderForGroup: reader [
1✔
193

1✔
194
        reader for: GLHGroup do: [ :mapping |
1✔
195
                mapping mapInstVars.
1✔
196
                (mapping mapInstVar: #projects) valueSchema: #ArrayOfProjects ].
1✔
197
        reader mapInstVarsFor: GLHProject.
1✔
198
        reader
1✔
199
                for: #ArrayOfProjects
1✔
200
                customDo: [ :customMappting |
1✔
201
                customMappting listOfElementSchema: GLHProject ].
1✔
202
        reader
1✔
203
                for: #ArrayOfGroups
1✔
204
                customDo: [ :customMappting |
1✔
205
                customMappting listOfElementSchema: GLHGroup ]
1✔
206
]
1✔
207

208
{ #category : 'private' }
209
GLHModelImporter >> convertApiFileAsFile: aAPIFile [
×
210

×
211
        aAPIFile type = 'tree' ifTrue: [ 
×
212
                ^ GLHFileDirectory new
×
213
                          name: aAPIFile name;
×
214
                          yourself ].
×
215
        ^ GLHFileBlob new
×
216
                  name: aAPIFile name;
×
217
                  yourself
×
218
]
×
219

220
{ #category : 'as yet unclassified' }
221
GLHModelImporter >> detectEntityType: aType overAttribut: aSelector equalTo: value [
×
222

×
223
        ^ (self glhModel allWithType: aType) detect: [ :entity |
×
224
                  (entity perform: aSelector) = value ] ifNone: [ nil ]. 
×
225
]
×
226

227
{ #category : 'as yet unclassified' }
228
GLHModelImporter >> filterCommitChanges: aCollection [
1✔
229

1✔
230
        ^ aCollection reject: [ :line |
1✔
231
                  | trimmedLine |
1✔
232
                  trimmedLine := line trimLeft.
1✔
233
                  (trimmedLine beginsWith: '---') or: [
1✔
234
                          (trimmedLine beginsWith: '+++') or: [
1✔
235
                                  trimmedLine beginsWith: '\ No newline at end of file' ] ] ]
1✔
236
]
1✔
237

238
{ #category : 'accessing' }
239
GLHModelImporter >> glhApi [
1✔
240

1✔
241
        ^ glhApi
1✔
242
]
1✔
243

244
{ #category : 'accessing' }
245
GLHModelImporter >> glhApi: anObject [
1✔
246

1✔
247
        glhApi := anObject
1✔
248
]
1✔
249

250
{ #category : #accessing }
251
GLHModelImporter >> glhModel [
1✔
252

1✔
253
        ^ glhModel
1✔
254
]
1✔
255

256
{ #category : #accessing }
257
GLHModelImporter >> glhModel: anObject [
1✔
258

1✔
259
        glhModel := anObject
1✔
260
]
1✔
261

262
{ #category : #'as yet unclassified' }
263
GLHModelImporter >> importActiveHumanUsers [
×
264

×
265
        | newlyFoundUser page foundUsers |
×
266
        page := 0.
×
267
        foundUsers := OrderedCollection new.
×
268
        newlyFoundUser := { true }.
×
269
        [ newlyFoundUser isNotEmpty ] whileTrue: [
×
270
                | results |
×
271
                page := page + 1.
×
272
                ('import users page ' , page printString) recordInfo.
×
273
                results := self glhApi
×
274
                                   usersHuman: true
×
275
                                   active: true
×
276
                                   withoutProjectBots: true
×
277
                                   perPage: 100
×
278
                                   page: page.
×
279

×
280
                newlyFoundUser := self parseUsersResult: results.
×
281
                "newlyFoundCommit do: [ :c | c repository: aProject repository ]."
×
282

×
283
                foundUsers addAll:
×
284
                        (self glhModel
×
285
                                 addAll: newlyFoundUser
×
286
                                 unless: self blockOnIdEquality) ].
×
287

×
288

×
289
        ^ foundUsers
×
290
]
×
291

292

293
{ #category : 'api' }
294
GLHModelImporter >> importAllGroups [
×
295

×
296
        | page foundGroups newlyFoundGroups |
×
297
        page := 0.
×
298
        foundGroups := OrderedCollection new.
×
299
        newlyFoundGroups := { true }.
×
300
        [ newlyFoundGroups isNotEmpty ] whileTrue: [
×
301
                | results |
×
302
                page := page + 1.
×
303
                results := self glhApi listGroupsWithTopLevelOnly: true page: page.
×
304

×
305
                newlyFoundGroups := generalReader
×
306
                                            on: results readStream;
×
307
                                            nextAs: #ArrayOfGroups.
×
308
                foundGroups addAll: newlyFoundGroups ].
×
309
        ^ foundGroups
×
310
]
×
311

312

313
{ #category : #'as yet unclassified' }
314
GLHModelImporter >> importAndLoadLatestsCommitsOfProject: aGLHProject [
×
315

×
316
        | commits |
×
317
        self completeImportProject: aGLHProject.
×
318
        commits := self importLastestCommitsOfProject: aGLHProject.
×
319
        commits do: [ :commit | self completeImportedCommit: commit ].
×
320
        self chainsCommitsFrom: commits.
×
321
        ^ commits
×
322
]
×
323

324
{ #category : #'private - api' }
325
GLHModelImporter >> importCommit: aCommitID ofProject: aGLHProject [
×
326

×
327
        | result parsedResult |
×
328
        (self glhModel allWithType: GLHCommit) asOrderedCollection
×
329
                detect: [ :commit | commit id = aCommitID ]
×
330
                ifFound: [ :commit | ^ commit ].
×
331
        result := self glhApi
×
332
                          commit: aCommitID
×
333
                          ofProject: aGLHProject id
×
334
                          withStat: false.
×
335
        parsedResult := self parseCommitResult: result.
×
336
        self
×
337
                addCommits: { parsedResult }
×
338
                toRepository: aGLHProject repository.
×
339
        ^ parsedResult
×
340
]
×
341

342
{ #category : 'as yet unclassified' }
343
GLHModelImporter >> importCommitOfProject: anProject withId: anID [
×
344

×
345
        | commit result |
×
346
        anID ifNil: [ ^ nil ].
×
347

×
348
        ('looking for commit ' , anID printString , ' in project : '
×
349
         , anProject id printString) recordInfo.
×
350

×
351
        commit := (self
×
352
                           detectEntityType: GLHCommit
×
353
                           overAttribut: #id
×
354
                           equalTo: anID) ifNil: [
×
355
                          result := self glhApi commit: anID ofProject: anProject id.
×
356
                          commit := (self parseCommitsResult: '[' , result , ']')
×
357
                                            first.
×
358

×
359
                          self glhModel add: commit unless: self blockOnIdEquality.
×
360
                          commit repository: anProject repository.
×
361

×
362
                          commit ].
×
363

×
364
        self withCommitDiffs ifTrue: [ self importDiffOfCommit: commit ].
×
365

×
366
        ^ commit
×
367
]
×
368

369

370
{ #category : 'private - api' }
371
GLHModelImporter >> importCommits: aGLHProject [
×
372
        "limited to the last 20 commits"
×
373

×
374
        | results parsedResults |
×
375
        results := self glhApi
×
376
                           commitsOfProject: aGLHProject id
×
377
                           forRefName: nil
×
378
                           since: nil
×
379
                           until: nil
×
380
                           path: nil
×
381
                           author: nil
×
382
                           all: nil
×
383
                           with_stats: true
×
384
                           firstParent: nil
×
385
                           order: nil
×
386
                           trailers: nil
×
387
                           perPage: nil
×
388
                           page: nil.
×
389
        parsedResults := self parseCommitsResult: results.
×
390
        self glhModel addAll: parsedResults unless: self blockOnIdEquality.
×
391

×
392
        parsedResults do: [ :commit |
×
393
                commit repository: aGLHProject repository ].
×
394

×
395
        self withCommitDiffs ifTrue: [
×
396
                parsedResults do: [ :commit | self importDiffOfCommit: commit ] ].
×
397
        
×
398
        ^ parsedResults. 
×
399
]
×
400

401
{ #category : 'as yet unclassified' }
402
GLHModelImporter >> importCommitsFollowing: aCommit upToDays: aNumberOfDay [
×
403
        "import the 'n' commits of a project starting from an initial 'aCommit' commit. 
×
404
        Lazy import does not import the entities inside the model"
×
405

×
406
        | date |
×
407
        date := aCommit created_at asDateAndTime.
×
408

×
409
        ^ self
×
410
                  importCommitsOfBranch: aCommit branch
×
411
                  forRefName: aCommit branch name
×
412
                  since: date
×
413
                  until: (date + aNumberOfDay day)
×
414
]
×
415

416
{ #category : 'commit' }
417
GLHModelImporter >> importCommitsOProject: aProject since: fromDate until: toDate [
×
418

×
419
        | newlyFoundCommit page foundCommit |
×
420
        page := 0.
×
421
        foundCommit := OrderedCollection new.
×
422
        newlyFoundCommit := { true }.
×
423
        [ newlyFoundCommit isNotEmpty ] whileTrue: [
×
424
                | results |
×
425
                page := page + 1.
×
426
                ('import commit page ' , page printString) recordInfo.
×
427
                results := self glhApi
×
428
                                   commitsOfProject: aProject id
×
429
                                   forRefName: nil
×
430
                                   since:
×
431
                                   (fromDate ifNotNil: [ fromDate asDateAndTime asString ])
×
432
                                   until:
×
433
                                   (toDate ifNotNil: [ toDate asDateAndTime asString ])
×
434
                                   path: nil
×
435
                                   author: nil
×
436
                                   all: true
×
437
                                   with_stats: true
×
438
                                   firstParent: nil
×
439
                                   order: nil
×
440
                                   trailers: nil
×
441
                                   perPage: 100
×
442
                                   page: page.
×
443

×
444
                newlyFoundCommit := self parseCommitsResult: results.
×
445
                "newlyFoundCommit do: [ :c | c repository: aProject repository ]."
×
446

×
447
                foundCommit addAll: (aProject repository commits
×
448
                        addAll: newlyFoundCommit
×
449
                        unless: self blockOnIdEquality). ].
×
450

×
451

×
452
        ^ self glhModel addAll: foundCommit unless: self blockOnIdEquality
×
453
]
×
454

455

456
{ #category : #commit }
457
GLHModelImporter >> importCommitsOf: aGLHProject withStats: aBoolean until: toDate [
×
458

×
459
        | newlyFoundCommit page |
×
460
        
×
461
        self deprecated: [  ] .
×
462
        
×
463
        page := 0.
×
464
        newlyFoundCommit := { true }.
×
465
        [ newlyFoundCommit isNotEmpty ] whileTrue: [
×
466
                | results parsedResults existingCommits |
×
467
                page := page + 1.
×
468
                ('import commit page ' , page printString) recordInfo.
×
469
                results := self glhApi
×
470
                                   commitsOfProject: aGLHProject id
×
471
                                   forRefName: nil
×
472
                                   since: nil
×
473
                                   until: nil
×
474
                                   path: nil
×
475
                                   author: nil
×
476
                                   all: nil
×
477
                                   with_stats: aBoolean
×
478
                                   firstParent: nil
×
479
                                   order: nil
×
480
                                   trailers: nil
×
481
                                   perPage: 100
×
482
                                   page: page.
×
483
                parsedResults := self parseCommitsResult: results.
×
484
                existingCommits := aGLHProject mooseModel allWithType: GLHCommit.
×
485

×
486
                newlyFoundCommit := parsedResults reject: [ :commitParsed |
×
487
                                            (toDate isNil or: [
×
488
                                                     commitParsed committed_date
×
489
                                                     < toDate asDateAndTime ]) or: [
×
490
                                                    existingCommits anySatisfy: [ :existingCommit |
×
491
                                                            existingCommit id = commitParsed id ] ] ].
×
492
                aGLHProject mooseModel addAll: newlyFoundCommit.
×
493
                aGLHProject repository commits addAll: newlyFoundCommit ].
×
494

×
495

×
496
        self withCommitDiffs ifTrue: [
×
497
                aGLHProject repository commits do: [ :commit |
×
498
                        self importDiffOfCommit: commit ] ]
×
499
]
×
500

501
{ #category : 'commit' }
502
GLHModelImporter >> importCommitsOfBranch: aGLHBranch forRefName: refName since: fromDate [
×
503

×
504
        ^ self
×
505
                  importCommitsOfBranch: aGLHBranch
×
506
                  forRefName: aGLHBranch name
×
507
                  since: fromDate
×
508
                  until: nil
×
509
]
×
510

511
{ #category : 'commit' }
512
GLHModelImporter >> importCommitsOfBranch: aGLHBranch forRefName: refName since: fromDate until: toDate [
×
513

×
514
        | newlyFoundCommit page foundCommit|
×
515
        page := 0.
×
516
        foundCommit := OrderedCollection new. 
×
517
        newlyFoundCommit := { true }.
×
518
        [ newlyFoundCommit isNotEmpty ] whileTrue: [
×
519
                | results |
×
520
                page := page + 1.
×
521
                ('import commit page ' , page printString) recordInfo.
×
522
                results := self glhApi
×
523
                                   commitsOfProject: aGLHBranch repository project id
×
524
                                   forRefName: aGLHBranch name
×
525
                                   since:
×
526
                                   (fromDate ifNotNil: [ fromDate asDateAndTime asString ])
×
527
                                   until:
×
528
                                   (toDate ifNotNil: [ toDate asDateAndTime asString ])
×
529
                                   path: nil
×
530
                                   author: nil
×
531
                                   all: nil
×
532
                                   with_stats: nil
×
533
                                   firstParent: nil
×
534
                                   order: nil
×
535
                                   trailers: nil
×
536
                                   perPage: 100
×
537
                                   page: page.
×
538

×
539
                newlyFoundCommit := self parseCommitsResult: results.
×
540
        aGLHBranch commits
×
541
                        addAll: newlyFoundCommit
×
542
                        unless: self blockOnIdEquality.
×
543
        foundCommit addAll: newlyFoundCommit.  
×
544
                        ].
×
545

×
546
        self glhModel
×
547
                addAll: aGLHBranch commits
×
548
                unless: self blockOnIdEquality.
×
549

×
550
        "self withCommitDiffs ifTrue: [
×
551
                aGLHBranch commits: [ :commit | self importDiffOfCommit: commit ] ]."
×
552

×
553
        ^ foundCommit
×
554
]
×
555

556
{ #category : 'commit' }
557
GLHModelImporter >> importCommitsOfBranch: aGLHBranch forRefName: refName until: toDate [
×
558

×
559
        ^ self
×
560
                  importCommitsOfBranch: aGLHBranch
×
561
                  forRefName: aGLHBranch name
×
562
                  since: nil
×
563
                  until: toDate
×
564
]
×
565

566
GLHModelImporter >> importContributedProjectsOfUser: aGLHUser [
×
567

×
568
        | newlyFoundElmts page foundElmts remaningProjects|
×
569
        page := 0.
×
570
        foundElmts := OrderedCollection new.
×
571
        newlyFoundElmts := { true }.
×
572
        [ newlyFoundElmts isNotEmpty ] whileTrue: [
×
573
                | results |
×
574
                page := page + 1.
×
575
                ('import contributed project of user ' , aGLHUser name , ' page '
×
576
                 , page printString) recordInfo.
×
577
                results := self glhApi 
×
578
                                   contributedProjectsOfUserId: aGLHUser id
×
579
                                   orderBy: 'last_activity_at'
×
580
                                   simple: true
×
581
                                   sort: 'desc'
×
582
                                   perPage: 100
×
583
                                   page: page.
×
584

×
585
                newlyFoundElmts := self parseArrayOfProject: results.
×
586

×
587
                foundElmts addAll:
×
588
                        (self glhModel
×
589
                                 addAll: newlyFoundElmts
×
590
                                 unless: self blockOnIdEquality) ].
×
591
]
×
592

593
{ #category : 'as yet unclassified' }
594
GLHModelImporter >> importCreatorOfCommit: aCommit [
×
595
        
×
596
        remaningProjects := self importProjects: ((foundElmts collect: #id) difference: ((self userCatalogue atId: aGLHUser id) at: #contributedProjects)).
×
597

×
598
        aGLHUser contributedProjects
×
599
                addAll: (foundElmts, remaningProjects)
×
600
                unless: self blockOnIdEquality.
×
601
                
×
602
        self userCatalogue addUser: aGLHUser withProjects: (aGLHUser contributedProjects collect: #id).
×
603

×
604
        ^ foundElmts
×
605
]
×
606

607
{ #category : #'as yet unclassified' }
NEW
608
GLHModelImporter >> importCreatorOfCommit2: aCommit [
×
609

×
610
        aCommit commitCreator ifNil: [                
×
611
                aCommit commitCreator:
×
612
                        (self importUserByUsername: aCommit author_name) ].
×
613
        self userCatalogue addUser: aCommit commitCreator withProject: aCommit repository project id.
×
614
        ^ aCommit commitCreator
×
615
]
×
616

617
{ #category : 'api' }
618
GLHModelImporter >> importDiffOfCommit: aCommit [
1✔
619

1✔
620
        | result diffsResult |
1✔
621
        aCommit diffs ifNotEmpty: [
1✔
622
                'Diff already importer: ' , aCommit short_id printString recordInfo.
1✔
623
                ^ aCommit diffs ].
1✔
624
        ('Import diff of commit: ' , aCommit short_id printString) recordInfo.
1✔
625
        result := self glhApi
1✔
626
                          commitDiff: aCommit id
1✔
627
                          ofProject: aCommit repository project id
1✔
628
                          unidiff: true.
1✔
629
        diffsResult := self newParseDiffResult: result.
1✔
630

1✔
631
        ^ aCommit diffs addAll: diffsResult unless: self blockForDiffEquality.
1✔
632

1✔
633
]
1✔
634

635
{ #category : 'private - api' }
636
GLHModelImporter >> importDirectoryFiles: aDirectoryFile OfBranch: aBranch [
×
637

×
638
        | result files apiFiles |
×
639
        result := self glhApi
×
640
                          treeOfRepository: aBranch repository project id
×
641
                          ofBranch: aBranch name
×
642
                          andPath: aDirectoryFile path , '/'.
×
643
        apiFiles := self parseFileTreeResult: result.
×
644
        files := apiFiles collect: [ :apiFile |
×
645
                         self convertApiFileAsFile: apiFile ].
×
646
        files do: [ :file |
×
647
                
×
648
                self glhModel add: file.
×
649
                aDirectoryFile addFile: file ].
×
650
        files
×
651
                select: [ :file | file isKindOf: GLHFileDirectory ]
×
652
                thenCollect: [ :file |
×
653
                self importDirectoryFiles: file OfBranch: aBranch ]
×
654
]
×
655

656
{ #category : 'private - api' }
657
GLHModelImporter >> importFilesOfBranch: aBranch [
×
658

×
659
        | result files apiFiles |
×
660
        result := self glhApi
×
661
                          treeOfRepository: aBranch repository project id
×
662
                          ofBranch: aBranch name
×
663
                          andPath: nil.
×
664
        apiFiles := self parseFileTreeResult: result.
×
665
        files := apiFiles collect: [ :apiFile | 
×
666
                         self convertApiFileAsFile: apiFile ].
×
667
        files do: [ :file | 
×
668
                self glhModel add: file.
×
669
                aBranch addFile: file ].
×
670
        files
×
671
                select: [ :file | file isKindOf: GLHFileDirectory ]
×
672
                thenCollect: [ :file | 
×
673
                self importDirectoryFiles: file OfBranch: aBranch ]
×
674
]
×
675

676
{ #category : 'api' }
677
GLHModelImporter >> importGroup: aGroupID [
1✔
678

1✔
679
        | result groupResult |
1✔
680
        ('Import group: ' , aGroupID printString) recordInfo.
1✔
681

1✔
682
        result := self glhApi group: aGroupID.
1✔
683
        groupResult := self parseGroupResult: result.
1✔
684
        groupResult := self addGroupResultToModel: groupResult.
1✔
685

1✔
686
        groupResult projects do: [ :project |
1✔
687
                self completeImportProject: project ].
1✔
688

1✔
689
        (self subGroupsOf: aGroupID) do: [ :subGroup |
1✔
690
                
1✔
691
                groupResult subGroups
1✔
692
                        add: (self importGroup: subGroup id)
1✔
693
                        unless: self blockOnIdEquality ].
1✔
694
        ^ groupResult
1✔
695
]
1✔
696

697
{ #category : 'api' }
698
GLHModelImporter >> importJobsOf: aPipeline [
×
699

×
700
        | result jobs |
×
701
        result := self glhApi
×
702
                          jobsOfProject: aPipeline project id
×
703
                          ofPipelines: aPipeline id.
×
704
        jobs := self parseJobsResult: result ofProject: aPipeline project.
×
705
        jobs do: [ :job | aPipeline addJob: job ].
×
706
        self glhModel addAll: jobs
×
707

×
708
]
×
709

710

711
{ #category : #'private - api' }
712
GLHModelImporter >> importLastestCommitsOfProject: aGLHProject [
1✔
713
        "limited to the last 50 commits"
1✔
714

1✔
715
        | results parsedResults |
1✔
716
        results := self glhApi
1✔
717
                           commitsOfProject: aGLHProject id
1✔
718
                           forRefName: nil
1✔
719
                           since: nil
1✔
720
                           until: nil
1✔
721
                           path: nil
1✔
722
                           author: nil
1✔
723
                           all: nil
1✔
724
                           with_stats: true
1✔
725
                           firstParent: nil
1✔
726
                           order: nil
1✔
727
                           trailers: nil
1✔
728
                           perPage: 50
1✔
729
                           page: nil.
1✔
730
        parsedResults := self parseCommitsResult: results.
1✔
731
        parsedResults := self glhModel addAll: parsedResults unless: self blockOnIdEquality.
1✔
732

1✔
733
        aGLHProject repository commits addAll: parsedResults unless: self blockOnIdEquality.
1✔
734
        "parsedResults do: [ :commit |
1✔
735
                commit repository: aGLHProject repository ]."
1✔
736

1✔
737
        self withCommitDiffs ifTrue: [
1✔
738
                parsedResults do: [ :commit | self importDiffOfCommit: commit ] ].
1✔
739

1✔
740
        ^ parsedResults
1✔
741
]
1✔
742

743
{ #category : 'commit' }
744
GLHModelImporter >> importParentCommitsOfCommit: aGLHCommit since: aDate [
×
745

×
746
        | parentsIds commits |
×
747
        commits := OrderedCollection new.
×
748
        aGLHCommit created_at asDateAndTime < aDate asDateAndTime ifTrue: [
×
749
                 
×
750
                ^ commits
×
751
                          add: aGLHCommit;
×
752
                          yourself ].
×
753

×
754
        parentsIds := aGLHCommit parent_ids.
×
755

×
756
        commits addAll: (parentsIds collect: [ :id |
×
757
                         self
×
758
                                 importCommitOfProject: aGLHCommit repository project
×
759
                                 withId: id ]).
×
760

×
761

×
762
        ^ (commits collect: [ :parentCommit |
×
763
                   self importParentCommitsOfCommit: parentCommit since: aDate ])
×
764
                  flatten
×
765
]
×
766

767
{ #category : 'private - api' }
768
GLHModelImporter >> importPipelinesOfProject: aGLHProject [
1✔
769

1✔
770
        (self pipelinesOf: aGLHProject id) do: [ :pipeline |
1✔
771
                self glhModel add: pipeline unless: self blockOnIdEquality .
1✔
772
                aGLHProject pipelines add: pipeline unless: self blockOnIdEquality]
1✔
773
]
1✔
774

775
{ #category : #projects }
776
GLHModelImporter >> importProject: aProjectID [
×
777

×
778
        | result projectResult |
×
779
        ('Import project with id: ' , aProjectID printString) recordInfo.
×
780

×
781
        result := self glhApi project: aProjectID.
×
782
        projectResult := self parseProjectResult: result.
×
783

×
784
        ^ self completeImportProject: projectResult
×
785
]
×
786

787
{ #category : 'imports' }
788
GLHModelImporter >> importProjects [
×
789

×
790
        ^ self importProjectsSince: nil
×
791
]
×
792

793
{ #category : 'projects' }
794
GLHModelImporter >> importProjects: aCollectionOfProjectID [
×
795

×
796
        ^ aCollectionOfProjectID collect: [ :id | self importProject: id ]
×
797
]
×
798

799
{ #category : 'imports' }
800
GLHModelImporter >> importProjectsSince: since [
×
801
        "heavy import of all projects"
×
802

×
803
        "copy import from commits"
×
804

×
805
        | newlyFoundProjects page foundProject amount |
×
806
        ('import all Projects since: ' , since printString) recordInfo.
×
807

×
808
        "number of projects per page"
×
809
        amount := 100.
×
810
        page := 0.
×
811
        foundProject := OrderedCollection new.
×
812
        newlyFoundProjects := { true }.
×
813
        [ newlyFoundProjects isNotEmpty ] whileTrue: [
×
814
                | results |
×
815
                page := page + 1.
×
816
                ('import projects page #' , page printString) recordInfo.
×
817

×
818
                results := self glhApi projects: amount since: since page: page.
×
819

×
820
                newlyFoundProjects := self glhModel
×
821
                                              addAll: (self parseArrayOfProject: results)
×
822
                                              unless: self blockOnIdEquality.
×
823
                foundProject addAll: newlyFoundProjects ].
×
824

×
825
        ^ foundProject
×
826
]
×
827

828
{ #category : 'private - api' }
829
GLHModelImporter >> importRepository: aGLHRepository [
1✔
830

1✔
831
        | resultBranches branches |
1✔
832
        [
1✔
833
        ('import the repository of project ' , aGLHRepository project name)
1✔
834
                recordInfo.
1✔
835

1✔
836
        resultBranches := self glhApi branchesOfRepository:
1✔
837
                                  aGLHRepository project id.
1✔
838
        branches := self parseBranchesResult: resultBranches.
1✔
839

1✔
840
        'import the branches of project ' recordInfo.
1✔
841

1✔
842
        branches := aGLHRepository branches
1✔
843
                            addAll: branches
1✔
844
                            unless: self blockOnNameEquality.
1✔
845
        branches := self glhModel
1✔
846
                            addAll: branches
1✔
847
                            unless: self blockOnNameEquality.
1✔
848

1✔
849

1✔
850
        self withFiles ifTrue: [
1✔
851
                branches do: [ :branch | self importFilesOfBranch: branch ] ] ]
1✔
852
                on: NeoJSONParseError
1✔
853
                do: [
1✔
854
                self inform: aGLHRepository project name , ' has no repository' ]
1✔
855
]
1✔
856

857
{ #category : 'private - api' }
858
GLHModelImporter >> importUser: aUserID [
1✔
859

1✔
860
        | result userResult |
1✔
861
        (self glhModel allWithType: GLHUser)
1✔
862
                detect: [ :user | user id = aUserID ]
1✔
863
                ifFound: [ :user | ^ user ].
1✔
864
        ('Import user: ' , aUserID printString) recordInfo.
1✔
865
        result := self glhApi user: aUserID.
1✔
866
        userResult := self parseUserResult: result.
1✔
867
        ^ self glhModel add: userResult unless: self blockOnIdEquality
1✔
868
]
1✔
869

870
{ #category : 'user' }
871
GLHModelImporter >> importUserByUsername: anUsername [
×
872

×
873
        | dicUsername resultUser |
×
874
        dicUsername := ((self glhModel allWithType: GLHUser) collect: [ :user |
×
875
                                user username -> user ]) asSet asDictionary.
×
876

×
877
        dicUsername addAll: self userCatalogue collectUsernames.
×
878

×
879

×
880
        resultUser := dicUsername
×
881
                              at: anUsername
×
882
                              ifAbsent: [ "thus we have to import this new user"
×
883
                                      | result userId searchResult |
×
884
                                      ('Import user with username: '
×
885
                                       , anUsername printString) recordInfo.
×
886
                                      result := self glhApi usersSearchByUsername:
×
887
                                                        anUsername.
×
888
                                      searchResult := NeoJSONReader fromString: result.
×
889

×
890
                                      (searchResult class = Dictionary and: [
×
891
                                               (searchResult at: #message) includesSubstring:
×
892
                                                       '403 Forbidden' ])
×
893
                                              ifTrue: [ "if the result is an 403 error we fake a new user"
×
894
                                                      self glhModel
×
895
                                                              add: (GLHUser new
×
896
                                                                               username: anUsername;
×
897
                                                                               name: anUsername;
×
898
                                                                               yourself)
×
899
                                                              unless: [ :nu :ou | nu username = ou username ] ]
×
900
                                              ifFalse: [
×
901
                                                      searchResult
×
902
                                                              ifEmpty: [ "results can be empty thus we force a new user with the info we have "
×
903
                                                                      self glhModel
×
904
                                                                              add: (GLHUser new
×
905
                                                                                               username: anUsername;
×
906
                                                                                               name: anUsername;
×
907
                                                                                               yourself)
×
908
                                                                              unless: [ :nu :ou | nu username = ou username ] ]
×
909
                                                              ifNotEmpty: [ "because we may already have the researched user, we look by ID in the model"
×
910
                                                                      userId := searchResult first at: #id.
×
911
                                                                      (self glhModel allWithType: GLHUser)
×
912
                                                                              detect: [ :user | user id = userId ]
×
913
                                                                              ifNone: [ self importUser: userId ] ] ] ].
×
914

×
915
        self userCatalogue addUser: resultUser withName: anUsername.
×
916

×
917
        ^ resultUser
×
918
]
×
919

920
{ #category : 'initialization' }
921
GLHModelImporter >> initReader [
1✔
922

1✔
923
        generalReader := NeoJSONReader new.
1✔
924
        self configureReaderForCommit: generalReader.
1✔
925
        self configureReaderForGroup: generalReader.
1✔
926
        self configureReaderForDiffs: generalReader. 
1✔
927
]
1✔
928

929
{ #category : 'initialization' }
930
GLHModelImporter >> initialize [
1✔
931

1✔
932
        super initialize.
1✔
933
        withCommitDiffs := false.
1✔
934
        withInitialCommits := false.
1✔
935
        withInitialMergeRequest := false.
1✔
936

1✔
937
        withCommitsSince := (Date today - 1 week) asDateAndTime.
1✔
938
        userCatalogue := GLHUserCatalogueV2 new
1✔
939
                                 anImporter: self;
1✔
940
                                 yourself.
1✔
941
        self initReader.
1✔
942

1✔
943
        currentImporter := self
1✔
944
]
1✔
945

946
{ #category : 'importer' }
947
GLHModelImporter >> loadAllProjectsFromRepositorySoftware [
×
948
        "heavy import that load all the active project inside the model. Only import the project entities"
×
949
        |projects|
×
950
        
×
951
        projects := self glhApi projects. 
×
952
]
×
953

954
GLHModelImporter >> makeGlobal [
×
955
        currentImporter := self
×
956
]
×
957

958

959
{ #category : 'private' }
960
GLHModelImporter >> newParseCommitResult: result [
×
961

×
962
        generalReader  on: result readStream.
×
963

×
964
        ^ generalReader nextAs: GLHCommit
×
965
]
×
966

967
{ #category : 'private' }
968
GLHModelImporter >> newParseDiffResult: result [
1✔
969

1✔
970
        generalReader on: result readStream.
1✔
971
        ^ generalReader nextAs: #ArrayOfDiffs
1✔
972
]
1✔
973

974
{ #category : 'parsing' }
975
GLHModelImporter >> parseArrayOfProject: arrayOfProjects [
×
976

×
977
        | reader |
×
978
        reader := NeoJSONReader on: arrayOfProjects readStream.
×
979
        reader
×
980
                for: #ArrayOfProjects
×
981
                customDo: [ :customMappting |
×
982
                customMappting listOfElementSchema: GLHProject ].
×
983
        reader for: GLHProject do: [ :mapping |
×
984
                mapping mapInstVar: #name to: #name.
×
985
                mapping mapInstVar: #description to: #description.
×
986
                mapping mapInstVar: #id to: #id.
×
987
                mapping mapInstVar: #archived to: #archived.
×
988
                mapping mapInstVar: #web_url to: #html_url.
×
989
                mapping mapInstVar: #topics to: #topics ].
×
990
        ^ reader nextAs: #ArrayOfProjects
×
991
]
×
992

993
{ #category : 'private' }
994
GLHModelImporter >> parseBranchesResult: result [
1✔
995

1✔
996
        | reader |
1✔
997
        reader := NeoJSONReader on: result readStream.
1✔
998
        reader mapInstVarsFor: GLHBranch.
1✔
999
        reader
1✔
1000
                for: #ArrayOfBranch
1✔
1001
                customDo: [ :customMappting | 
1✔
1002
                customMappting listOfElementSchema: GLHBranch ].
1✔
1003
        ^ reader nextAs: #ArrayOfBranch
1✔
1004
]
1✔
1005

1006
{ #category : 'private' }
1007
GLHModelImporter >> parseCommitResult: result [
×
1008

×
1009
        | reader |
×
1010
        reader := NeoJSONReader on: result readStream.
×
1011

×
1012
        reader for: GLHCommit do: [ :mapping |
×
1013
                mapping mapInstVars:
×
1014
                        #( id short_id title author_name author_email committer_name
×
1015
                           committer_email message web_url ).
×
1016
                (mapping mapInstVar: #authored_date) valueSchema: DateAndTime.
×
1017
                (mapping mapInstVar: #committed_date) valueSchema: DateAndTime.
×
1018
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
×
1019
                (mapping mapInstVar: #parent_ids) valueSchema: #ArrayOfIds.
×
1020
                mapping
×
1021
                        mapProperty: 'stats'
×
1022
                        getter: [ :el | "Not used" ]
×
1023
                        setter: [ :commit :value |
×
1024
                                commit deletions: (value at: #deletions).
×
1025
                                commit additions: (value at: #additions) ] ].
×
1026

×
1027
        reader for: DateAndTime customDo: [ :mapping |
×
1028
                mapping decoder: [ :string | DateAndTime fromString: string ] ].
×
1029

×
1030
        reader
×
1031
                for: #ArrayOfIds
×
1032
                customDo: [ :mapping | mapping decoder: [ :string | string ] ].
×
1033

×
1034

×
1035
        ^ reader nextAs: GLHCommit
×
1036
]
×
1037

1038
{ #category : 'private' }
1039
GLHModelImporter >> parseCommitsResult: result [
1✔
1040

1✔
1041
        | reader |
1✔
1042
        reader := NeoJSONReader on: result readStream.
1✔
1043

1✔
1044
          reader for: GLHCommit do: [ :mapping |
1✔
1045
                mapping mapInstVars:
1✔
1046
                        #( id short_id title author_name author_email committer_name
1✔
1047
                           committer_email message web_url ).
1✔
1048
                (mapping mapInstVar: #authored_date) valueSchema: DateAndTime.
1✔
1049
                (mapping mapInstVar: #committed_date) valueSchema: DateAndTime.
1✔
1050
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
1✔
1051
                (mapping mapInstVar: #parent_ids) valueSchema: #ArrayOfIds.
1✔
1052
                mapping
1✔
1053
                        mapProperty: 'stats'
1✔
1054
                        getter: [ :el | "Not used" ]
1✔
1055
                        setter: [ :commit :value |
1✔
1056
                                commit deletions: (value at: #deletions).
1✔
1057
                                commit additions: (value at: #additions) ] ].
1✔
1058

1✔
1059
        reader for: DateAndTime customDo: [ :mapping |
1✔
1060
                mapping decoder: [ :string | DateAndTime fromString: string ] ].
1✔
1061

1✔
1062
        reader
1✔
1063
                for: #ArrayOfIds
1✔
1064
                customDo: [ :mapping | mapping decoder: [ :string | string ] ].
1✔
1065
  
1✔
1066
        reader
1✔
1067
                for: #ArrayOfCommit
1✔
1068
                customDo: [ :customMappting |
1✔
1069
                customMappting listOfElementSchema: GLHCommit ].
1✔
1070

1✔
1071
        ^ reader nextAs: #ArrayOfCommit
1✔
1072
]
1✔
1073

1074
{ #category : #private }
1075
GLHModelImporter >> parseDiffResult: result [
×
1076

×
1077
        | reader |
×
1078
        self
×
1079
                deprecated: 'Use #newParseDiffResult: instead'
×
1080
                on: '28 June 2024'
×
1081
                in:
×
1082
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
×
1083
        reader := NeoJSONReader on: result readStream.
×
1084
        reader for: GLHDiff do: [ :mapping |
×
1085
                mapping mapInstVars:
×
1086
                        #( deleted_file new_file new_path old_path renamed_file ).
×
1087
                mapping mapInstVar: #diffString to: #diff ].
×
1088

×
1089
        reader
×
1090
                for: #ArrayOfDiffs
×
1091
                customDo: [ :customMappting |
×
1092
                customMappting listOfElementSchema: GLHDiff ].
×
1093
        ^ reader nextAs: #ArrayOfDiffs
×
1094
]
×
1095

1096
{ #category : 'private' }
1097
GLHModelImporter >> parseFileTreeResult: aResult [
×
1098

×
1099
        | reader |
×
1100
        reader := NeoJSONReader on: aResult readStream.
×
1101
        reader mapInstVarsFor: GLHApiFile.
×
1102
        reader
×
1103
                for: #ArrayOfFile
×
1104
                customDo: [ :customMappting | 
×
1105
                customMappting listOfElementSchema: GLHApiFile ].
×
1106
        ^ reader nextAs: #ArrayOfFile
×
1107
]
×
1108

1109
{ #category : 'private' }
1110
GLHModelImporter >> parseGroupResult: aResult [
1✔
1111

1✔
1112
        | reader |
1✔
1113

1✔
1114
        reader := NeoJSONReader on: aResult readStream.
1✔
1115
        reader for: GLHGroup do: [ :mapping |
1✔
1116
                mapping mapInstVars.
1✔
1117
                (mapping mapInstVar: #projects) valueSchema: #ArrayOfProjects ].
1✔
1118
        reader mapInstVarsFor: GLHProject.
1✔
1119
        reader
1✔
1120
                for: #ArrayOfProjects
1✔
1121
                customDo: [ :customMappting |
1✔
1122
                customMappting listOfElementSchema: GLHProject ].
1✔
1123
        ^ reader nextAs: GLHGroup
1✔
1124
]
1✔
1125

1126
{ #category : 'private' }
1127
GLHModelImporter >> parseJobsResult: result ofProject: aProject [
×
1128

×
1129
        | reader |
×
1130
        reader := NeoJSONReader on: result readStream.
×
1131
        reader for: GLHJob do: [ :mapping |
×
1132
                mapping mapInstVars: #( id allow_failure web_url name ).
×
1133

×
1134
                mapping
×
1135
                        mapProperty: #user
×
1136
                        getter: [ :object | #ignore ]
×
1137
                        setter: [ :object :value |
×
1138
                        object user: (self importUser: (value at: #id)) ].
×
1139

×
1140
                mapping
×
1141
                        mapProperty: #commit
×
1142
                        getter: [ :object | #ignore ]
×
1143
                        setter: [ :object :value |
×
1144
                                value ifNotNil: [
×
1145
                                        object commit:
×
1146
                                                (self importCommit: (value at: #id) ofProject: aProject) ] ].
×
1147

×
1148
                mapping
×
1149
                        mapProperty: #duration
×
1150
                        getter: [ :object | #ignore ]
×
1151
                        setter: [ :object :value |
×
1152
                        value ifNotNil: [ object duration: value seconds ] ] ].
×
1153

×
1154
        reader
×
1155
                for: #ArrayOfGLHJob
×
1156
                customDo: [ :customMappting |
×
1157
                customMappting listOfElementSchema: GLHJob ].
×
1158
        ^ reader nextAs: #ArrayOfGLHJob
×
1159
]
×
1160

1161
{ #category : 'private' }
1162
GLHModelImporter >> parsePipelinesResult: result [
1✔
1163

1✔
1164
        | reader |
1✔
1165
        
1✔
1166
        (result includesSubstring: '{"message":"40' )ifTrue: [ ^ {  } ].
1✔
1167
        
1✔
1168
        reader := NeoJSONReader on: result readStream.
1✔
1169
        reader mapInstVarsFor: GLHPipeline.
1✔
1170
        reader for: GLHPipeline do: [ :mapping |
1✔
1171
                mapping
1✔
1172
                        mapProperty: #created_at
1✔
1173
                        getter: [ :object | #ignore ]
1✔
1174
                        setter: [ :object :value |
1✔
1175
                        object runDate: (DateAndTime fromString: value) ] ].
1✔
1176
        reader
1✔
1177
                for: #ArrayOfPipelines
1✔
1178
                customDo: [ :customMappting |
1✔
1179
                customMappting listOfElementSchema: GLHPipeline ].
1✔
1180
        ^ reader nextAs: #ArrayOfPipelines
1✔
1181
]
1✔
1182

1183

1184
{ #category : #parsing }
1185
GLHModelImporter >> parseProjectResult: aResult [ 
×
1186
                | reader |
×
1187
        reader := NeoJSONReader on: aResult readStream.
×
1188
        reader for: GLHProject do: [ :mapping |
×
1189
                mapping mapInstVars. ].
×
1190
"        reader mapInstVarsFor: GLHProject."
×
1191

×
1192
        ^ reader nextAs: GLHProject
×
1193
]
×
1194

×
1195

×
1196
{ #category : 'private' }
×
1197
GLHModelImporter >> parseSubGroupResult: aResult [
×
1198

×
1199
        | reader |
×
1200
        reader := NeoJSONReader on: aResult readStream.
×
1201
        self configureReaderForGroup: reader.
×
1202
        ^ reader nextAs: #ArrayOfGroups
×
1203
]
×
1204

×
1205
{ #category : 'private' }
×
1206
GLHModelImporter >> parseUserResult: result [
×
1207

×
1208
        | reader |
×
1209
        reader := NeoJSONReader on: result readStream.
×
1210
        reader mapInstVarsFor: GLHUser.
×
1211
        ^ reader nextAs: GLHUser
×
1212
]
×
1213

×
1214

×
1215
{ #category : #private }
×
1216
GLHModelImporter >> parseUsersResult: result [
×
1217

×
1218
        | reader |
×
1219
        reader := NeoJSONReader on: result readStream.
×
1220

×
1221
        reader mapInstVarsFor: GLHUser.
×
1222

×
1223
        reader
×
1224
                for: #ArrayOfUser
×
1225
                customDo: [ :customMappting |
×
1226
                customMappting listOfElementSchema: GLHUser ].
×
1227

×
1228
        ^ reader nextAs: #ArrayOfUser
×
1229
]
×
1230

×
1231

×
1232
{ #category : 'private - api' }
×
1233
GLHModelImporter >> pipelinesOf: aProjectID [
×
1234

×
1235
        | result |
×
1236
        ('Search pipelines of: ' , aProjectID printString) recordInfo.
×
1237
        result := self glhApi pipelinesOfProject: aProjectID.
×
1238
        ^ self parsePipelinesResult: result .
×
1239
]
×
1240

×
1241
{ #category : 'as yet unclassified' }
×
1242
GLHModelImporter >> selectEntityType: aType overAttribut: aSelector equalTo: value [
×
1243

×
1244
        ^ (self glhModel allWithType: aType)
×
1245
                select: [ :entity | (entity perform: aSelector) = value ]
×
1246
]
×
1247

×
1248
{ #category : 'private - api' }
×
1249
GLHModelImporter >> subGroupsOf: aGroupID [
×
1250

×
1251
        | results parsedResult result page |
×
1252
        ('Search subgroup of: ' , aGroupID printString) recordInfo.
×
1253
        results := OrderedCollection new.
×
1254
        page := 0.
×
1255
        
×
1256
        parsedResult := { true }.
×
1257
        [ parsedResult size > 0 ] whileTrue: [ 
×
1258
                result := self glhApi subgroupsOfGroup: aGroupID page: page.
×
1259
                parsedResult := self parseSubGroupResult: result.
×
1260
                results addAll: parsedResult.
×
1261
                                page := page + 1. ].
×
1262
        
×
1263
        ^ results
×
1264
]
×
1265

×
1266
{ #category : #accessing }
×
1267
GLHModelImporter >> userCatalogue [
×
1268
        ^ userCatalogue 
×
1269
]
×
1270

×
1271
{ #category : #accessing }
×
1272
GLHModelImporter >> userCatalogue: aGLHUserCatalogue [
×
1273

×
1274
        userCatalogue := aGLHUserCatalogue.
×
1275
        aGLHUserCatalogue anImporter: self. 
×
1276
]
×
1277

×
1278
{ #category : 'accessing' }
×
1279
GLHModelImporter >> withCommitDiffs [
×
1280

×
1281
        ^ withCommitDiffs
×
1282
]
×
1283

×
1284
{ #category : 'accessing' }
×
1285
GLHModelImporter >> withCommitDiffs: anObject [
×
1286

×
1287
        withCommitDiffs := anObject
×
1288
]
×
1289

×
1290
{ #category : 'accessing' }
×
1291
GLHModelImporter >> withInitialCommits: boolean [
×
1292
        withInitialCommits := boolean 
×
1293
]
×
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