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

moosetechnology / GitProjectHealth / 11142135122

02 Oct 2024 10:26AM UTC coverage: 53.293% (-0.004%) from 53.297%
11142135122

Pull #74

github

web-flow
Merge bd5399315 into 0c3ed6880
Pull Request #74: feat: bitbucket importer

32 of 50 new or added lines in 8 files covered. (64.0%)

14 existing lines in 1 file now uncovered.

6902 of 12951 relevant lines covered (53.29%)

0.53 hits per line

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

44.46
/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
        #category : #'GitLabHealth-Model-Importer'
13
}
14

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

×
19
        "I return the list of added commits"
×
20

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

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

42
{ #category : #'as yet unclassified' }
43
GLHModelImporter >> blockEqualityOn: aSymbol [
1✔
44
        ^ [ :existing :new |
1✔
45
          (existing perform: aSymbol) = (new perform: aSymbol) ]
1✔
46
]
1✔
47

48
{ #category : #equality }
49
GLHModelImporter >> blockForDiffEquality [
1✔
50
        ^ [ :existing :new |
1✔
51
                        existing diffString size = new diffString size and: [
1✔
52
                                existing diffString = new diffString ] ]
1✔
53
]
1✔
54

55
{ #category : #equality }
56
GLHModelImporter >> blockOnIdEquality [
1✔
57

1✔
58
        ^ [ :existing :new |
1✔
59
          existing id = new id ]
1✔
60
]
1✔
61

62
{ #category : #equality }
63
GLHModelImporter >> blockOnNameEquality [
1✔
64

1✔
65
        ^ self blockEqualityOn: #name
1✔
66
]
1✔
67

68
{ #category : #'as yet unclassified' }
69
GLHModelImporter >> chainsCommitsFrom: commitsCollection [
1✔
70

1✔
71
        | dic |
1✔
72
        
1✔
73
        ('Chains ', commitsCollection size printString , ' commits') recordInfo.
1✔
74
        
1✔
75
        dic := ((self glhModel allWithType: GLHCommit) collect: [ :commit |
1✔
76
                        commit id -> commit ]) asSet asDictionary.
1✔
77

1✔
78
        commitsCollection do: [ :commit |
1✔
79
                commit parent_ids do: [ :parentId | 
1✔
80
                        dic
1✔
81
                                at: parentId
1✔
82
                                ifPresent: [ :parentCommit |
1✔
83
                                        parentCommit childCommits
1✔
84
                                                add: commit
1✔
85
                                                unless: self blockOnIdEquality ]
1✔
86
                                ifAbsent: [  ] ] ].
1✔
87
        ^ commitsCollection
1✔
88
]
1✔
89

90
{ #category : #'private - api' }
91
GLHModelImporter >> completeImportProject: aGLHProject [
1✔
92

1✔
93
        | importedProject |
1✔
94
        ('Complete import of project: ' , aGLHProject id printString)
1✔
95
                recordInfo.
1✔
96
        aGLHProject repository ifNotNil: [ ^ aGLHProject ].
1✔
97

1✔
98
        importedProject := self glhModel
1✔
99
                                   add: aGLHProject
1✔
100
                                   unless: self blockOnIdEquality.
1✔
101

1✔
102
        self importPipelinesOfProject: importedProject.
1✔
103

1✔
104
        "aGLHProject creator: (self importUser: aGLHProject creator_id)."
1✔
105

1✔
106
        (self importUser: importedProject creator_id) addCreatedProject:
1✔
107
                importedProject.
1✔
108

1✔
109

1✔
110
        importedProject repository: GLHRepository new.
1✔
111
        self glhModel add: importedProject repository.
1✔
112
        self importRepository: importedProject repository.
1✔
113

1✔
114
        ^ importedProject
1✔
115
]
1✔
116

117
{ #category : #'as yet unclassified' }
118
GLHModelImporter >> completeImportedCommit: aCommit [
1✔
119

1✔
120
        ('completing commit: ' , aCommit short_id printString) recordInfo.
1✔
121
        self importCreatorOfCommit: aCommit.
1✔
122

1✔
123
        self withCommitDiffs ifTrue: [
1✔
124
                | diffs |
1✔
125
                aCommit diffs ifEmpty: [
1✔
126
                        diffs := self importDiffOfCommit: aCommit.
1✔
127
                        self glhModel addAll: diffs unless: self blockForDiffEquality ] ].
1✔
128

1✔
129
        ^ aCommit
1✔
130
]
1✔
131

132
{ #category : #'private - configure reader' }
133
GLHModelImporter >> configureReaderForCommit: reader [
1✔
134

1✔
135
          reader for: GLHCommit do: [ :mapping |
1✔
136
                mapping mapInstVars:
1✔
137
                        #( id short_id title author_name author_email committer_name
1✔
138
                           committer_email message web_url ).
1✔
139
                (mapping mapInstVar: #authored_date) valueSchema: DateAndTime.
1✔
140
                (mapping mapInstVar: #committed_date) valueSchema: DateAndTime.
1✔
141
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
1✔
142
                (mapping mapInstVar: #parent_ids) valueSchema: #ArrayOfIds.
1✔
143
                mapping
1✔
144
                        mapProperty: 'stats'
1✔
145
                        getter: [ :el | "Not used" ]
1✔
146
                        setter: [ :commit :value |
1✔
147
                                commit deletions: (value at: #deletions).
1✔
148
                                commit additions: (value at: #additions) ] ].
1✔
149

1✔
150
        reader for: DateAndTime customDo: [ :mapping |
1✔
151
                mapping decoder: [ :string | DateAndTime fromString: string ] ].
1✔
152

1✔
153
        reader
1✔
154
                for: #ArrayOfIds
1✔
155
                customDo: [ :mapping | mapping decoder: [ :string | string ] ].
1✔
156
  
1✔
157
        reader
1✔
158
                for: #ArrayOfCommit
1✔
159
                customDo: [ :customMappting |
1✔
160
                customMappting listOfElementSchema: GLHCommit ].
1✔
161

1✔
162
]
1✔
163

164
{ #category : #'private - configure reader' }
165
GLHModelImporter >> configureReaderForDiffs: reader [
1✔
166

1✔
167
        reader for: GLHDiff do: [ :mapping |
1✔
168
                mapping mapInstVars:
1✔
169
                        #( deleted_file new_file new_path old_path renamed_file ).
1✔
170
                mapping mapInstVar: #diffString to: #diff ].
1✔
171

1✔
172
        reader
1✔
173
                for: #ArrayOfDiffs
1✔
174
                customDo: [ :customMappting |
1✔
175
                customMappting listOfElementSchema: GLHDiff ].
1✔
176
        ^ reader
1✔
177
]
1✔
178

179
{ #category : #'private - configure reader' }
180
GLHModelImporter >> configureReaderForGroup: reader [
1✔
181

1✔
182
        reader for: GLHGroup do: [ :mapping |
1✔
183
                mapping mapInstVars.
1✔
184
                (mapping mapInstVar: #projects) valueSchema: #ArrayOfProjects ].
1✔
185
        reader mapInstVarsFor: GLHProject.
1✔
186
        reader
1✔
187
                for: #ArrayOfProjects
1✔
188
                customDo: [ :customMappting |
1✔
189
                customMappting listOfElementSchema: GLHProject ].
1✔
190
        reader
1✔
191
                for: #ArrayOfGroups
1✔
192
                customDo: [ :customMappting |
1✔
193
                customMappting listOfElementSchema: GLHGroup ]
1✔
194
]
1✔
195

196
{ #category : #private }
197
GLHModelImporter >> convertApiFileAsFile: aAPIFile [
×
198

×
199
        aAPIFile type = 'tree' ifTrue: [ 
×
200
                ^ GLHFileDirectory new
×
201
                          name: aAPIFile name;
×
202
                          yourself ].
×
203
        ^ GLHFileBlob new
×
204
                  name: aAPIFile name;
×
205
                  yourself
×
206
]
×
207

208
{ #category : #'as yet unclassified' }
209
GLHModelImporter >> detectEntityType: aType overAttribut: aSelector equalTo: value [
1✔
210

1✔
211
        ^ (self glhModel allWithType: aType) detect: [ :entity |
1✔
212
                  (entity perform: aSelector) = value ] ifNone: [ nil ]. 
1✔
213
]
1✔
214

215
{ #category : #'as yet unclassified' }
216
GLHModelImporter >> filterCommitChanges: aCollection [
1✔
217

1✔
218
        ^ aCollection reject: [ :line |
1✔
219
                  | trimmedLine |
1✔
220
                  trimmedLine := line trimLeft.
1✔
221
                  (trimmedLine beginsWith: '---') or: [
1✔
222
                          (trimmedLine beginsWith: '+++') or: [
1✔
223
                                  trimmedLine beginsWith: '\ No newline at end of file' ] ] ]
1✔
224
]
1✔
225

226
{ #category : #accessing }
227
GLHModelImporter >> glhApi [
1✔
228

1✔
229
        ^ glhApi
1✔
230
]
1✔
231

232
{ #category : #accessing }
233
GLHModelImporter >> glhApi: anObject [
1✔
234

1✔
235
        glhApi := anObject
1✔
236
]
1✔
237

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

1✔
241
        ^ glhModel
1✔
242
]
1✔
243

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

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

250
{ #category : #'as yet unclassified' }
251
GLHModelImporter >> importActiveHumanUsers [
×
252

×
253
        | newlyFoundUser page foundUsers |
×
254
        page := 0.
×
255
        foundUsers := OrderedCollection new.
×
256
        newlyFoundUser := { true }.
×
257
        [ newlyFoundUser isNotEmpty ] whileTrue: [
×
258
                | results |
×
259
                page := page + 1.
×
260
                ('import users page ' , page printString) recordInfo.
×
261
                results := self glhApi
×
262
                                   usersHuman: true
×
263
                                   active: true
×
264
                                   withoutProjectBots: true
×
265
                                   perPage: 100
×
266
                                   page: page.
×
267

×
268
                newlyFoundUser := self parseUsersResult: results.
×
269
                "newlyFoundCommit do: [ :c | c repository: aProject repository ]."
×
270

×
271
                foundUsers addAll:
×
272
                        (self glhModel
×
273
                                 addAll: newlyFoundUser
×
274
                                 unless: self blockOnIdEquality) ].
×
275

×
276

×
277
        ^ foundUsers
×
278
]
×
279

280
{ #category : #api }
281
GLHModelImporter >> importAllGroups [
×
282

×
283
        | page foundGroups newlyFoundGroups |
×
284
        page := 0.
×
285
        foundGroups := OrderedCollection new.
×
286
        newlyFoundGroups := { true }.
×
287
        [ newlyFoundGroups isNotEmpty ] whileTrue: [
×
288
                | results |
×
289
                page := page + 1.
×
290
                results := self glhApi listGroupsWithTopLevelOnly: true page: page.
×
291

×
292
                newlyFoundGroups := generalReader
×
293
                                            on: results readStream;
×
294
                                            nextAs: #ArrayOfGroups.
×
295
                foundGroups addAll: newlyFoundGroups ].
×
296
        ^ foundGroups
×
297
]
×
298

299
{ #category : #'as yet unclassified' }
300
GLHModelImporter >> importAndLoadLatestsCommitsOfProject: aGLHProject [
×
301

×
302
        | commits |
×
303
        self completeImportProject: aGLHProject.
×
304
        commits := self importLastestCommitsOfProject: aGLHProject.
×
305
        commits do: [ :commit | self completeImportedCommit: commit ].
×
306
        self chainsCommitsFrom: commits.
×
307
        ^ commits
×
308
]
×
309

310
{ #category : #'private - api' }
311
GLHModelImporter >> importCommit: aCommitID ofProject: aGLHProject [
×
312

×
313
        | result parsedResult |
×
314
        (self glhModel allWithType: GLHCommit) asOrderedCollection
×
315
                detect: [ :commit | commit id = aCommitID ]
×
316
                ifFound: [ :commit | ^ commit ].
×
317
        result := self glhApi
×
318
                          commit: aCommitID
×
319
                          ofProject: aGLHProject id
×
320
                          withStat: true.
×
321
        parsedResult := self parseCommitResult: result.
×
322
        self
×
323
                addCommits: { parsedResult }
×
324
                toRepository: aGLHProject repository.
×
325
        ^ parsedResult
×
326
]
×
327

328
{ #category : #'as yet unclassified' }
329
GLHModelImporter >> importCommitOfProject: anProject withId: anID [
1✔
330

1✔
331
        | commit result |
1✔
332
        anID ifNil: [ ^ nil ].
1✔
333

1✔
334
        ('looking for commit ' , anID printString , ' in project : '
1✔
335
         , anProject id printString) recordInfo.
1✔
336

1✔
337
        commit := (self
1✔
338
                           detectEntityType: GLHCommit
1✔
339
                           overAttribut: #id
1✔
340
                           equalTo: anID) ifNil: [
1✔
341
                          result := self glhApi commit: anID ofProject: anProject id.
1✔
342
                          commit := (self parseCommitsResult: '[' , result , ']')
1✔
343
                                            first.
1✔
344

1✔
345
                          self glhModel add: commit unless: self blockOnIdEquality.
1✔
346
                          commit repository: anProject repository.
1✔
347

1✔
348
                          commit ].
1✔
349

1✔
350
        self withCommitDiffs ifTrue: [ self importDiffOfCommit: commit ].
1✔
351

1✔
352
        ^ commit
1✔
353
]
1✔
354

355
{ #category : #'private - api' }
356
GLHModelImporter >> importCommits: aGLHProject [
×
357
        "limited to the last 20 commits"
×
358

×
359
        | results parsedResults |
×
360
        results := self glhApi
×
361
                           commitsOfProject: aGLHProject id
×
362
                           forRefName: nil
×
363
                           since: nil
×
364
                           until: nil
×
365
                           path: nil
×
366
                           author: nil
×
367
                           all: nil
×
368
                           with_stats: true
×
369
                           firstParent: nil
×
370
                           order: nil
×
371
                           trailers: nil
×
372
                           perPage: nil
×
373
                           page: nil.
×
374
        parsedResults := self parseCommitsResult: results.
×
375
        self glhModel addAll: parsedResults unless: self blockOnIdEquality.
×
376

×
377
        parsedResults do: [ :commit |
×
378
                commit repository: aGLHProject repository ].
×
379

×
380
        self withCommitDiffs ifTrue: [
×
381
                parsedResults do: [ :commit | self importDiffOfCommit: commit ] ].
×
382
        
×
383
        ^ parsedResults. 
×
384
]
×
385

386
{ #category : #'as yet unclassified' }
387
GLHModelImporter >> importCommitsFollowing: aCommit upToDays: aNumberOfDay [
×
388
        "import the 'n' commits of a project starting from an initial 'aCommit' commit. 
×
389
        Lazy import does not import the entities inside the model"
×
390

×
391
        | date |
×
392
        date := aCommit created_at asDateAndTime.
×
393

×
394
        ^ self
×
395
                  importCommitsOfBranch: aCommit branch
×
396
                  forRefName: aCommit branch name
×
397
                  since: date
×
398
                  until: (date + aNumberOfDay day)
×
399
]
×
400

401
{ #category : #commit }
UNCOV
402
GLHModelImporter >> importCommitsOf: aGLHProject withStats: aBoolean until: toDate [
×
UNCOV
403

×
UNCOV
404
        | newlyFoundCommit page |
×
UNCOV
405
        
×
UNCOV
406
        self deprecated: [  ] .
×
UNCOV
407
        
×
UNCOV
408
        page := 0.
×
UNCOV
409
        newlyFoundCommit := { true }.
×
UNCOV
410
        [ newlyFoundCommit isNotEmpty ] whileTrue: [
×
UNCOV
411
                | results parsedResults existingCommits |
×
UNCOV
412
                page := page + 1.
×
UNCOV
413
                ('import commit page ' , page printString) recordInfo.
×
UNCOV
414
                results := self glhApi
×
UNCOV
415
                                   commitsOfProject: aGLHProject id
×
416
                                   forRefName: nil
×
417
                                   since: nil
×
418
                                   until: nil
×
419
                                   path: nil
×
420
                                   author: nil
×
421
                                   all: nil
×
422
                                   with_stats: aBoolean
×
423
                                   firstParent: nil
×
424
                                   order: nil
×
425
                                   trailers: nil
×
426
                                   perPage: 100
×
427
                                   page: page.
×
428
                parsedResults := self parseCommitsResult: results.
×
429
                existingCommits := aGLHProject mooseModel allWithType: GLHCommit.
×
430

×
431
                newlyFoundCommit := parsedResults reject: [ :commitParsed |
×
432
                                            (toDate isNil or: [
×
433
                                                     commitParsed committed_date
×
434
                                                     < toDate asDateAndTime ]) or: [
×
435
                                                    existingCommits anySatisfy: [ :existingCommit |
×
436
                                                            existingCommit id = commitParsed id ] ] ].
×
437
                aGLHProject mooseModel addAll: newlyFoundCommit.
×
438
                aGLHProject repository commits addAll: newlyFoundCommit ].
×
439

×
440

×
441
        self withCommitDiffs ifTrue: [
×
442
                aGLHProject repository commits do: [ :commit |
×
443
                        self importDiffOfCommit: commit ] ]
×
444
]
×
445

446
{ #category : #commit }
447
GLHModelImporter >> importCommitsOfBranch: aGLHBranch forRefName: refName since: fromDate [
×
448

×
449
        ^ self
×
450
                  importCommitsOfBranch: aGLHBranch
×
451
                  forRefName: aGLHBranch name
×
452
                  since: fromDate
×
453
                  until: nil
×
454
]
×
455

456
{ #category : #commit }
457
GLHModelImporter >> importCommitsOfBranch: aGLHBranch forRefName: refName since: fromDate until: toDate [
×
458

×
459
        | newlyFoundCommit page foundCommit|
×
460
        page := 0.
×
461
        foundCommit := OrderedCollection new. 
×
462
        newlyFoundCommit := { true }.
×
463
        [ newlyFoundCommit isNotEmpty ] whileTrue: [
×
464
                | results |
×
465
                page := page + 1.
×
466
                ('import commit page ' , page printString) recordInfo.
×
467
                results := self glhApi
×
468
                                   commitsOfProject: aGLHBranch repository project id
×
469
                                   forRefName: aGLHBranch name
×
470
                                   since:
×
471
                                   (fromDate ifNotNil: [ fromDate asDateAndTime asString ])
×
472
                                   until:
×
473
                                   (toDate ifNotNil: [ toDate asDateAndTime asString ])
×
474
                                   path: nil
×
475
                                   author: nil
×
476
                                   all: nil
×
477
                                   with_stats: nil
×
478
                                   firstParent: nil
×
479
                                   order: nil
×
480
                                   trailers: nil
×
481
                                   perPage: 100
×
482
                                   page: page.
×
483

×
484
                newlyFoundCommit := self parseCommitsResult: results.
×
485
        aGLHBranch commits
×
486
                        addAll: newlyFoundCommit
×
487
                        unless: self blockOnIdEquality.
×
488
        foundCommit addAll: newlyFoundCommit.  
×
489
                        ].
×
490

×
491
        self glhModel
×
492
                addAll: aGLHBranch commits
×
493
                unless: self blockOnIdEquality.
×
494

×
495
        "self withCommitDiffs ifTrue: [
×
496
                aGLHBranch commits: [ :commit | self importDiffOfCommit: commit ] ]."
×
497

×
498
        ^ foundCommit
×
499
]
×
500

501
{ #category : #commit }
502
GLHModelImporter >> importCommitsOfBranch: aGLHBranch forRefName: refName until: toDate [
×
503

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

511
{ #category : #commit }
512
GLHModelImporter >> importCommitsOfProject: aProject since: fromDate until: toDate [
1✔
513

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

1✔
539
                newlyFoundCommit := self parseCommitsResult: results.
1✔
540
                "newlyFoundCommit do: [ :c | c repository: aProject repository ]."
1✔
541

1✔
542
                foundCommit addAll: (aProject repository commits
1✔
543
                        addAll: newlyFoundCommit
1✔
544
                        unless: self blockOnIdEquality). ].
1✔
545

1✔
546

1✔
547
        ^ self glhModel addAll: foundCommit unless: self blockOnIdEquality
1✔
548
]
1✔
549

550
{ #category : #'as yet unclassified' }
NEW
551
GLHModelImporter >> importContributedProjectsOfUser: aGLHUser [
×
NEW
552

×
NEW
553
        | newlyFoundElmts page foundElmts remaningProjects |
×
NEW
554
        page := 0.
×
NEW
555
        foundElmts := OrderedCollection new.
×
NEW
556
        newlyFoundElmts := { true }.
×
NEW
557
        [ newlyFoundElmts isNotEmpty ] whileTrue: [
×
NEW
558
                | results |
×
NEW
559
                page := page + 1.
×
NEW
560
                ('import contributed project of user ' , aGLHUser name , ' page '
×
NEW
561
                 , page printString) recordInfo.
×
NEW
562
                results := self glhApi
×
563
                                   contributedProjectsOfUserId: aGLHUser id
×
564
                                   orderBy: 'last_activity_at'
×
565
                                   simple: true
×
566
                                   sort: 'desc'
×
567
                                   perPage: 100
×
568
                                   page: page.
×
569

×
570
                newlyFoundElmts := self parseArrayOfProject: results.
×
571

×
572
                foundElmts addAll:
×
573
                        (self glhModel
×
574
                                 addAll: newlyFoundElmts
×
575
                                 unless: self blockOnIdEquality) ].
×
576
        remaningProjects := self importProjects:
×
577
                                    ((foundElmts collect: #id) difference:
×
578
                                             ((self userCatalogue atId: aGLHUser id) at:
×
579
                                                      #contributedProjects)).
×
580

×
581
        aGLHUser contributedProjects
×
582
                addAll: foundElmts , remaningProjects
×
583
                unless: self blockOnIdEquality.
×
584

×
585
        self userCatalogue
×
586
                addUser: aGLHUser
×
587
                withProjects: (aGLHUser contributedProjects collect: #id).
×
588

×
589
        ^ foundElmts
×
590
]
×
591

592
{ #category : #'as yet unclassified' }
593
GLHModelImporter >> importCreatorOfCommit: aCommit [
1✔
594

1✔
595
        aCommit commitCreator ifNil: [                
1✔
596
                aCommit commitCreator:
1✔
597
                        (self importUserByUsername: aCommit author_name) ].
1✔
598
        self userCatalogue addUser: aCommit commitCreator withProject: aCommit repository project id.
1✔
599
        ^ aCommit commitCreator
1✔
600
]
1✔
601

602
{ #category : #api }
603
GLHModelImporter >> importDiffOfCommit: aCommit [
1✔
604

1✔
605
        | result diffsResult |
1✔
606
        aCommit diffs ifNotEmpty: [
1✔
607
                'Diff already importer: ' , aCommit short_id printString recordInfo.
1✔
608
                ^ aCommit diffs ].
1✔
609
        ('Import diff of commit: ' , aCommit short_id printString) recordInfo.
1✔
610
        result := self glhApi
1✔
611
                          commitDiff: aCommit id
1✔
612
                          ofProject: aCommit repository project id
1✔
613
                          unidiff: true.
1✔
614
        diffsResult := self newParseDiffResult: result.
1✔
615

1✔
616
        ^ aCommit diffs addAll: diffsResult unless: self blockForDiffEquality.
1✔
617

1✔
618
]
1✔
619

620
{ #category : #'private - api' }
621
GLHModelImporter >> importDirectoryFiles: aDirectoryFile OfBranch: aBranch [
×
622

×
623
        | result files apiFiles |
×
624
        result := self glhApi
×
625
                          treeOfRepository: aBranch repository project id
×
626
                          ofBranch: aBranch name
×
627
                          andPath: aDirectoryFile path , '/'.
×
628
        apiFiles := self parseFileTreeResult: result.
×
629
        files := apiFiles collect: [ :apiFile |
×
630
                         self convertApiFileAsFile: apiFile ].
×
631
        files do: [ :file |
×
632
                
×
633
                self glhModel add: file.
×
634
                aDirectoryFile addFile: file ].
×
635
        files
×
636
                select: [ :file | file isKindOf: GLHFileDirectory ]
×
637
                thenCollect: [ :file |
×
638
                self importDirectoryFiles: file OfBranch: aBranch ]
×
639
]
×
640

641
{ #category : #'private - api' }
642
GLHModelImporter >> importFilesOfBranch: aBranch [
×
643

×
644
        | result files apiFiles |
×
645
        result := self glhApi
×
646
                          treeOfRepository: aBranch repository project id
×
647
                          ofBranch: aBranch name
×
648
                          andPath: nil.
×
649
        apiFiles := self parseFileTreeResult: result.
×
650
        files := apiFiles collect: [ :apiFile | 
×
651
                         self convertApiFileAsFile: apiFile ].
×
652
        files do: [ :file | 
×
653
                self glhModel add: file.
×
654
                aBranch addFile: file ].
×
655
        files
×
656
                select: [ :file | file isKindOf: GLHFileDirectory ]
×
657
                thenCollect: [ :file | 
×
658
                self importDirectoryFiles: file OfBranch: aBranch ]
×
659
]
×
660

661
{ #category : #api }
662
GLHModelImporter >> importGroup: aGroupID [
1✔
663

1✔
664
        | result groupResult |
1✔
665
        ('Import group: ' , aGroupID printString) recordInfo.
1✔
666

1✔
667
        result := self glhApi group: aGroupID.
1✔
668
        groupResult := self parseGroupResult: result.
1✔
669
        groupResult := self addGroupResultToModel: groupResult.
1✔
670

1✔
671
        groupResult projects do: [ :project |
1✔
672
                self completeImportProject: project ].
1✔
673

1✔
674
        (self subGroupsOf: aGroupID) do: [ :subGroup |
1✔
675
                
1✔
676
                groupResult subGroups
1✔
677
                        add: (self importGroup: subGroup id)
1✔
678
                        unless: self blockOnIdEquality ].
1✔
679
        ^ groupResult
1✔
680
]
1✔
681

682
{ #category : #api }
683
GLHModelImporter >> importJobsOf: aPipeline [
×
684

×
685
        | result jobs |
×
686
        result := self glhApi
×
687
                          jobsOfProject: aPipeline project id
×
688
                          ofPipelines: aPipeline id.
×
689
        jobs := self parseJobsResult: result ofProject: aPipeline project.
×
690
        jobs do: [ :job | aPipeline addJob: job ].
×
691
        self glhModel addAll: jobs
×
692

×
693
]
×
694

695
{ #category : #'private - api' }
696
GLHModelImporter >> importLastestCommitsOfProject: aGLHProject [
1✔
697
        "limited to the last 50 commits"
1✔
698

1✔
699
        | results parsedResults |
1✔
700
        results := self glhApi
1✔
701
                           commitsOfProject: aGLHProject id
1✔
702
                           forRefName: nil
1✔
703
                           since: nil
1✔
704
                           until: nil
1✔
705
                           path: nil
1✔
706
                           author: nil
1✔
707
                           all: nil
1✔
708
                           with_stats: true
1✔
709
                           firstParent: nil
1✔
710
                           order: nil
1✔
711
                           trailers: nil
1✔
712
                           perPage: 50
1✔
713
                           page: nil.
1✔
714
        parsedResults := self parseCommitsResult: results.
1✔
715
        parsedResults := self glhModel addAll: parsedResults unless: self blockOnIdEquality.
1✔
716

1✔
717
        aGLHProject repository commits addAll: parsedResults unless: self blockOnIdEquality.
1✔
718
        "parsedResults do: [ :commit |
1✔
719
                commit repository: aGLHProject repository ]."
1✔
720

1✔
721
        self withCommitDiffs ifTrue: [
1✔
722
                parsedResults do: [ :commit | self importDiffOfCommit: commit ] ].
1✔
723

1✔
724
        ^ parsedResults
1✔
725
]
1✔
726

727
{ #category : #commit }
728
GLHModelImporter >> importParentCommitsOfCommit: aGLHCommit since: aDate [
×
729

×
730
        | parentsIds commits |
×
731
        commits := OrderedCollection new.
×
732
        aGLHCommit created_at asDateAndTime < aDate asDateAndTime ifTrue: [
×
733
                 
×
734
                ^ commits
×
735
                          add: aGLHCommit;
×
736
                          yourself ].
×
737

×
738
        parentsIds := aGLHCommit parent_ids.
×
739

×
740
        commits addAll: (parentsIds collect: [ :id |
×
741
                         self
×
742
                                 importCommitOfProject: aGLHCommit repository project
×
743
                                 withId: id ]).
×
744

×
745

×
746
        ^ (commits collect: [ :parentCommit |
×
747
                   self importParentCommitsOfCommit: parentCommit since: aDate ])
×
748
                  flatten
×
749
]
×
750

751
{ #category : #'private - api' }
752
GLHModelImporter >> importPipelinesOfProject: aGLHProject [
1✔
753

1✔
754
        (self pipelinesOf: aGLHProject id) do: [ :pipeline |
1✔
755
                self glhModel add: pipeline unless: self blockOnIdEquality .
1✔
756
                aGLHProject pipelines add: pipeline unless: self blockOnIdEquality]
1✔
757
]
1✔
758

759
{ #category : #projects }
760
GLHModelImporter >> importProject: aProjectID [
×
761

×
762
        | result projectResult |
×
763
        ('Import project with id: ' , aProjectID printString) recordInfo.
×
764

×
765
        result := self glhApi project: aProjectID.
×
766
        projectResult := self parseProjectResult: result.
×
767

×
768
        ^ self completeImportProject: projectResult
×
769
]
×
770

771
{ #category : #imports }
772
GLHModelImporter >> importProjects [
×
773

×
774
        ^ self importProjectsSince: nil
×
775
]
×
776

777
{ #category : #projects }
778
GLHModelImporter >> importProjects: aCollectionOfProjectID [
×
779

×
780
        ^ aCollectionOfProjectID collect: [ :id | self importProject: id ]
×
781
]
×
782

783
{ #category : #imports }
784
GLHModelImporter >> importProjectsSince: since [
×
785
        "heavy import of all projects"
×
786

×
787
        "copy import from commits"
×
788

×
789
        | newlyFoundProjects page foundProject amount |
×
790
        ('import all Projects since: ' , since printString) recordInfo.
×
791

×
792
        "number of projects per page"
×
793
        amount := 100.
×
794
        page := 0.
×
795
        foundProject := OrderedCollection new.
×
796
        newlyFoundProjects := { true }.
×
797
        [ newlyFoundProjects isNotEmpty ] whileTrue: [
×
798
                | results |
×
799
                page := page + 1.
×
800
                ('import projects page #' , page printString) recordInfo.
×
801

×
802
                results := self glhApi projects: amount since: since page: page.
×
803

×
804
                newlyFoundProjects := self glhModel
×
805
                                              addAll: (self parseArrayOfProject: results)
×
806
                                              unless: self blockOnIdEquality.
×
807
                foundProject addAll: newlyFoundProjects ].
×
808

×
809
        ^ foundProject
×
810
]
×
811

812
{ #category : #'private - api' }
813
GLHModelImporter >> importRepository: aGLHRepository [
1✔
814

1✔
815
        | resultBranches branches |
1✔
816
        [
1✔
817
        ('import the repository of project ' , aGLHRepository project name)
1✔
818
                recordInfo.
1✔
819

1✔
820
        resultBranches := self glhApi branchesOfRepository:
1✔
821
                                  aGLHRepository project id.
1✔
822
        branches := self parseBranchesResult: resultBranches.
1✔
823

1✔
824
        'import the branches of project ' recordInfo.
1✔
825

1✔
826
        branches := aGLHRepository branches
1✔
827
                            addAll: branches
1✔
828
                            unless: self blockOnNameEquality.
1✔
829
        branches := self glhModel
1✔
830
                            addAll: branches
1✔
831
                            unless: self blockOnNameEquality.
1✔
832

1✔
833

1✔
834
        self withFiles ifTrue: [
1✔
835
                branches do: [ :branch | self importFilesOfBranch: branch ] ] ]
1✔
836
                on: NeoJSONParseError
1✔
837
                do: [
1✔
838
                self inform: aGLHRepository project name , ' has no repository' ]
1✔
839
]
1✔
840

841
{ #category : #'private - api' }
842
GLHModelImporter >> importUser: aUserID [
1✔
843

1✔
844
        | result userResult |
1✔
845
        (self glhModel allWithType: GLHUser)
1✔
846
                detect: [ :user | user id = aUserID ]
1✔
847
                ifFound: [ :user | ^ user ].
1✔
848
        ('Import user: ' , aUserID printString) recordInfo.
1✔
849
        result := self glhApi user: aUserID.
1✔
850
        userResult := self parseUserResult: result.
1✔
851
        ^ self glhModel add: userResult unless: self blockOnIdEquality
1✔
852
]
1✔
853

854
{ #category : #user }
855
GLHModelImporter >> importUserByUsername: anUsername [
1✔
856

1✔
857
        | dicUsername resultUser |
1✔
858
        dicUsername := ((self glhModel allWithType: GLHUser) collect: [ :user |
1✔
859
                                user username -> user ]) asSet asDictionary.
1✔
860

1✔
861
        dicUsername addAll: self userCatalogue collectUsernames.
1✔
862

1✔
863

1✔
864
        resultUser := dicUsername
1✔
865
                              at: anUsername
1✔
866
                              ifAbsent: [ "thus we have to import this new user"
1✔
867
                                      | result userId searchResult |
1✔
868
                                      ('Import user with username: '
1✔
869
                                       , anUsername printString) recordInfo.
1✔
870
                                      result := self glhApi usersSearchByUsername:
1✔
871
                                                        anUsername.
1✔
872
                                      searchResult := NeoJSONReader fromString: result.
1✔
873

1✔
874
                                      (searchResult class = Dictionary and: [
1✔
875
                                               (searchResult at: #message) includesSubstring:
1✔
876
                                                       '403 Forbidden' ])
1✔
877
                                              ifTrue: [ "if the result is an 403 error we fake a new user"
1✔
878
                                                      self glhModel
1✔
879
                                                              add: (GLHUser new
1✔
880
                                                                               username: anUsername;
1✔
881
                                                                               name: anUsername;
1✔
882
                                                                               yourself)
1✔
883
                                                              unless: [ :nu :ou | nu username = ou username ] ]
1✔
884
                                              ifFalse: [
1✔
885
                                                      searchResult
1✔
886
                                                              ifEmpty: [ "results can be empty thus we force a new user with the info we have "
1✔
887
                                                                      self glhModel
1✔
888
                                                                              add: (GLHUser new
1✔
889
                                                                                               username: anUsername;
1✔
890
                                                                                               name: anUsername;
1✔
891
                                                                                               yourself)
1✔
892
                                                                              unless: [ :nu :ou | nu username = ou username ] ]
1✔
893
                                                              ifNotEmpty: [ "because we may already have the researched user, we look by ID in the model"
1✔
894
                                                                      userId := searchResult first at: #id.
1✔
895
                                                                      (self glhModel allWithType: GLHUser)
1✔
896
                                                                              detect: [ :user | user id = userId ]
1✔
897
                                                                              ifNone: [ self importUser: userId ] ] ] ].
1✔
898

1✔
899
        self userCatalogue addUser: resultUser withName: anUsername.
1✔
900

1✔
901
        ^ resultUser
1✔
902
]
1✔
903

904
{ #category : #initialization }
905
GLHModelImporter >> initReader [
1✔
906

1✔
907
        generalReader := NeoJSONReader new.
1✔
908
        self configureReaderForCommit: generalReader.
1✔
909
        self configureReaderForGroup: generalReader.
1✔
910
        self configureReaderForDiffs: generalReader. 
1✔
911
]
1✔
912

913
{ #category : #initialization }
914
GLHModelImporter >> initialize [
1✔
915

1✔
916
        super initialize.
1✔
917
        withCommitDiffs := false.
1✔
918
        withInitialCommits := false.
1✔
919
        withInitialMergeRequest := false.
1✔
920

1✔
921
        withCommitsSince := (Date today - 1 week) asDateAndTime.
1✔
922
        userCatalogue := GLHUserCatalogueV2 new
1✔
923
                                 anImporter: self;
1✔
924
                                 yourself.
1✔
925
        self initReader.
1✔
926

1✔
927
        currentImporter := self
1✔
928
]
1✔
929

930
{ #category : #importer }
931
GLHModelImporter >> loadAllProjectsFromRepositorySoftware [
×
932
        "heavy import that load all the active project inside the model. Only import the project entities"
×
933
        |projects|
×
934
        
×
935
        projects := self glhApi projects. 
×
936
]
×
937

938
{ #category : #'as yet unclassified' }
939
GLHModelImporter >> makeGlobal [
×
940
        ^ self makeGlobal: DateAndTime now printString.
×
941
]
×
942

943
{ #category : #'as yet unclassified' }
944
GLHModelImporter >> makeGlobal: aLabel [ 
×
945

×
946
        currentImporter := currentImporter ifNil: [ OrderedDictionary new ].
×
947
        currentImporter at: aLabel put: self. 
×
948
        ^ self
×
949
]
×
950

951
{ #category : #private }
952
GLHModelImporter >> newParseCommitResult: result [
×
953

×
954
        generalReader  on: result readStream.
×
955

×
956
        ^ generalReader nextAs: GLHCommit
×
957
]
×
958

959
{ #category : #private }
960
GLHModelImporter >> newParseDiffResult: result [
1✔
961

1✔
962
        generalReader on: result readStream.
1✔
963
        ^ generalReader nextAs: #ArrayOfDiffs
1✔
964
]
1✔
965

966
{ #category : #parsing }
967
GLHModelImporter >> parseArrayOfProject: arrayOfProjects [
×
968

×
969
        | reader |
×
970
        reader := NeoJSONReader on: arrayOfProjects readStream.
×
971
        reader
×
972
                for: #ArrayOfProjects
×
973
                customDo: [ :customMappting |
×
974
                customMappting listOfElementSchema: GLHProject ].
×
975
        reader for: GLHProject do: [ :mapping |
×
976
                mapping mapInstVar: #name to: #name.
×
977
                mapping mapInstVar: #description to: #description.
×
978
                mapping mapInstVar: #id to: #id.
×
979
                mapping mapInstVar: #archived to: #archived.
×
980
                mapping mapInstVar: #web_url to: #html_url.
×
981
                mapping mapInstVar: #topics to: #topics ].
×
982
        ^ reader nextAs: #ArrayOfProjects
×
983
]
×
984

985
{ #category : #private }
986
GLHModelImporter >> parseBranchesResult: result [
1✔
987

1✔
988
        | reader |
1✔
989
        reader := NeoJSONReader on: result readStream.
1✔
990
        reader mapInstVarsFor: GLHBranch.
1✔
991
        reader
1✔
992
                for: #ArrayOfBranch
1✔
993
                customDo: [ :customMappting | 
1✔
994
                customMappting listOfElementSchema: GLHBranch ].
1✔
995
        ^ reader nextAs: #ArrayOfBranch
1✔
996
]
1✔
997

998
{ #category : #private }
999
GLHModelImporter >> parseCommitResult: result [
×
1000

×
1001
        | reader |
×
1002
        reader := NeoJSONReader on: result readStream.
×
1003

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

×
1019
        reader for: DateAndTime customDo: [ :mapping |
×
1020
                mapping decoder: [ :string | DateAndTime fromString: string ] ].
×
1021

×
1022
        reader
×
1023
                for: #ArrayOfIds
×
1024
                customDo: [ :mapping | mapping decoder: [ :string | string ] ].
×
1025

×
1026

×
1027
        ^ reader nextAs: GLHCommit
×
1028
]
×
1029

1030
{ #category : #private }
1031
GLHModelImporter >> parseCommitsResult: result [
1✔
1032

1✔
1033
        | reader |
1✔
1034
        reader := NeoJSONReader on: result readStream.
1✔
1035

1✔
1036
          reader for: GLHCommit do: [ :mapping |
1✔
1037
                mapping mapInstVars:
1✔
1038
                        #( id short_id title author_name author_email committer_name
1✔
1039
                           committer_email message web_url ).
1✔
1040
                (mapping mapInstVar: #authored_date) valueSchema: DateAndTime.
1✔
1041
                (mapping mapInstVar: #committed_date) valueSchema: DateAndTime.
1✔
1042
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
1✔
1043
                (mapping mapInstVar: #parent_ids) valueSchema: #ArrayOfIds.
1✔
1044
                mapping
1✔
1045
                        mapProperty: 'stats'
1✔
1046
                        getter: [ :el | "Not used" ]
1✔
1047
                        setter: [ :commit :value |
1✔
1048
                                commit deletions: (value at: #deletions).
1✔
1049
                                commit additions: (value at: #additions) ] ].
1✔
1050

1✔
1051
        reader for: DateAndTime customDo: [ :mapping |
1✔
1052
                mapping decoder: [ :string | DateAndTime fromString: string ] ].
1✔
1053

1✔
1054
        reader
1✔
1055
                for: #ArrayOfIds
1✔
1056
                customDo: [ :mapping | mapping decoder: [ :string | string ] ].
1✔
1057
  
1✔
1058
        reader
1✔
1059
                for: #ArrayOfCommit
1✔
1060
                customDo: [ :customMappting |
1✔
1061
                customMappting listOfElementSchema: GLHCommit ].
1✔
1062

1✔
1063
        ^ reader nextAs: #ArrayOfCommit
1✔
1064
]
1✔
1065

1066
{ #category : #private }
1067
GLHModelImporter >> parseDiffResult: result [
×
1068

×
1069
        | reader |
×
1070
        self
×
1071
                deprecated: 'Use #newParseDiffResult: instead'
×
1072
                on: '28 June 2024'
×
1073
                in:
×
1074
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
×
1075
        reader := NeoJSONReader on: result readStream.
×
1076
        reader for: GLHDiff do: [ :mapping |
×
1077
                mapping mapInstVars:
×
1078
                        #( deleted_file new_file new_path old_path renamed_file ).
×
1079
                mapping mapInstVar: #diffString to: #diff ].
×
1080

×
1081
        reader
×
1082
                for: #ArrayOfDiffs
×
1083
                customDo: [ :customMappting |
×
1084
                customMappting listOfElementSchema: GLHDiff ].
×
1085
        ^ reader nextAs: #ArrayOfDiffs
×
1086
]
×
1087

1088
{ #category : #private }
1089
GLHModelImporter >> parseFileTreeResult: aResult [
×
1090

×
1091
        | reader |
×
1092
        reader := NeoJSONReader on: aResult readStream.
×
1093
        reader mapInstVarsFor: GLHApiFile.
×
1094
        reader
×
1095
                for: #ArrayOfFile
×
1096
                customDo: [ :customMappting | 
×
1097
                customMappting listOfElementSchema: GLHApiFile ].
×
1098
        ^ reader nextAs: #ArrayOfFile
×
1099
]
×
1100

1101
{ #category : #private }
1102
GLHModelImporter >> parseGroupResult: aResult [
1✔
1103

1✔
1104
        | reader |
1✔
1105

1✔
1106
        reader := NeoJSONReader on: aResult readStream.
1✔
1107
        reader for: GLHGroup do: [ :mapping |
1✔
1108
                mapping mapInstVars.
1✔
1109
                (mapping mapInstVar: #projects) valueSchema: #ArrayOfProjects ].
1✔
1110
        reader mapInstVarsFor: GLHProject.
1✔
1111
        reader
1✔
1112
                for: #ArrayOfProjects
1✔
1113
                customDo: [ :customMappting |
1✔
1114
                customMappting listOfElementSchema: GLHProject ].
1✔
1115
        ^ reader nextAs: GLHGroup
1✔
1116
]
1✔
1117

1118
{ #category : #private }
1119
GLHModelImporter >> parseJobsResult: result ofProject: aProject [
×
1120

×
1121
        | reader |
×
1122
        reader := NeoJSONReader on: result readStream.
×
1123
        reader for: GLHJob do: [ :mapping |
×
1124
                mapping mapInstVars: #( id allow_failure web_url name ).
×
1125

×
1126
                mapping
×
1127
                        mapProperty: #user
×
1128
                        getter: [ :object | #ignore ]
×
1129
                        setter: [ :object :value |
×
1130
                        object user: (self importUser: (value at: #id)) ].
×
1131

×
1132
                mapping
×
1133
                        mapProperty: #commit
×
1134
                        getter: [ :object | #ignore ]
×
1135
                        setter: [ :object :value |
×
1136
                                value ifNotNil: [
×
1137
                                        object commit:
×
1138
                                                (self importCommit: (value at: #id) ofProject: aProject) ] ].
×
1139

×
1140
                mapping
×
1141
                        mapProperty: #duration
×
1142
                        getter: [ :object | #ignore ]
×
1143
                        setter: [ :object :value |
×
1144
                        value ifNotNil: [ object duration: value seconds ] ] ].
×
1145

×
1146
        reader
×
1147
                for: #ArrayOfGLHJob
×
1148
                customDo: [ :customMappting |
×
1149
                customMappting listOfElementSchema: GLHJob ].
×
1150
        ^ reader nextAs: #ArrayOfGLHJob
×
1151
]
×
1152

1153
{ #category : #private }
1154
GLHModelImporter >> parsePipelinesResult: result [
1✔
1155

1✔
1156
        | reader |
1✔
1157
        
1✔
1158
        (result includesSubstring: '{"message":"40' )ifTrue: [ ^ {  } ].
1✔
1159
        
1✔
1160
        reader := NeoJSONReader on: result readStream.
1✔
1161
        reader mapInstVarsFor: GLHPipeline.
1✔
1162
        reader for: GLHPipeline do: [ :mapping |
1✔
1163
                mapping
1✔
1164
                        mapProperty: #created_at
1✔
1165
                        getter: [ :object | #ignore ]
1✔
1166
                        setter: [ :object :value |
1✔
1167
                        object runDate: (DateAndTime fromString: value) ] ].
1✔
1168
        reader
1✔
1169
                for: #ArrayOfPipelines
1✔
1170
                customDo: [ :customMappting |
1✔
1171
                customMappting listOfElementSchema: GLHPipeline ].
1✔
1172
        ^ reader nextAs: #ArrayOfPipelines
1✔
1173
]
1✔
1174

1175
{ #category : #parsing }
1176
GLHModelImporter >> parseProjectResult: aResult [ 
×
1177
                | reader |
×
1178
        reader := NeoJSONReader on: aResult readStream.
×
1179
        reader for: GLHProject do: [ :mapping |
×
1180
                mapping mapInstVars. ].
×
1181
"        reader mapInstVarsFor: GLHProject."
×
1182

×
1183
        ^ reader nextAs: GLHProject
×
1184
]
×
1185

×
1186
{ #category : #private }
×
1187
GLHModelImporter >> parseSubGroupResult: aResult [
×
1188

×
1189
        | reader |
×
1190
        reader := NeoJSONReader on: aResult readStream.
×
1191
        self configureReaderForGroup: reader.
×
1192
        ^ reader nextAs: #ArrayOfGroups
×
1193
]
×
1194

×
1195
{ #category : #private }
×
1196
GLHModelImporter >> parseUserResult: result [
×
1197

×
1198
        | reader |
×
1199
        reader := NeoJSONReader on: result readStream.
×
1200
        reader mapInstVarsFor: GLHUser.
×
1201
        ^ reader nextAs: GLHUser
×
1202
]
×
1203

×
1204
{ #category : #private }
×
1205
GLHModelImporter >> parseUsersResult: result [
×
1206

×
1207
        | reader |
×
1208
        reader := NeoJSONReader on: result readStream.
×
1209

×
1210
        reader mapInstVarsFor: GLHUser.
×
1211

×
1212
        reader
×
1213
                for: #ArrayOfUser
×
1214
                customDo: [ :customMappting |
×
1215
                customMappting listOfElementSchema: GLHUser ].
×
1216

×
1217
        ^ reader nextAs: #ArrayOfUser
×
1218
]
×
1219

×
1220
{ #category : #'private - api' }
×
1221
GLHModelImporter >> pipelinesOf: aProjectID [
×
1222

×
1223
        | result |
×
1224
        ('Search pipelines of: ' , aProjectID printString) recordInfo.
×
1225
        result := self glhApi pipelinesOfProject: aProjectID.
×
1226
        ^ self parsePipelinesResult: result .
×
1227
]
×
1228

×
1229
{ #category : #'as yet unclassified' }
×
1230
GLHModelImporter >> selectEntityType: aType overAttribut: aSelector equalTo: value [
×
1231

×
1232
        ^ (self glhModel allWithType: aType)
×
1233
                select: [ :entity | (entity perform: aSelector) = value ]
×
1234
]
×
1235

×
1236
{ #category : #'private - api' }
×
1237
GLHModelImporter >> subGroupsOf: aGroupID [
×
1238

×
1239
        | results parsedResult result page |
×
1240
        ('Search subgroup of: ' , aGroupID printString) recordInfo.
×
1241
        results := OrderedCollection new.
×
1242
        page := 0.
×
1243
        
×
1244
        parsedResult := { true }.
×
1245
        [ parsedResult size > 0 ] whileTrue: [ 
×
1246
                result := self glhApi subgroupsOfGroup: aGroupID page: page.
×
1247
                parsedResult := self parseSubGroupResult: result.
×
1248
                results addAll: parsedResult.
×
1249
                                page := page + 1. ].
×
1250
        
×
1251
        ^ results
×
1252
]
×
1253

×
1254
{ #category : #accessing }
×
1255
GLHModelImporter >> userCatalogue [
×
1256
        ^ userCatalogue 
×
1257
]
×
1258

×
1259
{ #category : #accessing }
×
1260
GLHModelImporter >> userCatalogue: aGLHUserCatalogue [
×
1261

×
1262
        userCatalogue := aGLHUserCatalogue.
×
1263
        aGLHUserCatalogue anImporter: self. 
×
1264
]
×
1265

×
1266
{ #category : #accessing }
×
1267
GLHModelImporter >> withCommitDiffs [
×
1268

×
1269
        ^ withCommitDiffs
×
1270
]
×
1271

×
1272
{ #category : #accessing }
×
1273
GLHModelImporter >> withCommitDiffs: anObject [
×
1274

×
1275
        withCommitDiffs := anObject
×
1276
]
×
1277

×
1278
{ #category : #accessing }
×
1279
GLHModelImporter >> withInitialCommits: boolean [
×
1280
        withInitialCommits := boolean 
×
1281
]
×
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