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

moosetechnology / GitProjectHealth / 10880334038

16 Sep 2024 08:38AM UTC coverage: 20.325% (-0.2%) from 20.538%
10880334038

Pull #54

github

web-flow
Merge 9db8bd0be into aef27716a
Pull Request #54: Metrics fixing

20 of 234 new or added lines in 20 files covered. (8.55%)

252 existing lines in 18 files now uncovered.

1961 of 9648 relevant lines covered (20.33%)

0.2 hits per line

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

30.57
/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 : #'as yet unclassified' }
NEW
19
GLHModelImporter class >> importers [
×
NEW
20
        ^ currentImporter 
×
NEW
21
]
×
22

23
{ #category : #initialization }
NEW
24
GLHModelImporter class >> reset [
×
NEW
25
        currentImporter := nil.
×
UNCOV
26
]
×
27

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

×
32
        "I return the list of added commits"
×
33

×
34
        | existingCommits newlyFoundCommit |
×
35
        existingCommits := aProjectRepository mooseModel allWithType:
×
36
                                   GLHCommit.
×
37
        newlyFoundCommit := commitsList reject: [ :commitParsed |
×
38
                                    existingCommits anySatisfy: [ :existingCommit |
×
39
                                            existingCommit id = commitParsed id ] ].
×
40
        aProjectRepository mooseModel addAll: newlyFoundCommit.
×
41
        aProjectRepository commits addAll: newlyFoundCommit.
×
42
        ^ newlyFoundCommit
×
43
]
×
44

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

55
{ #category : 'as yet unclassified' }
56
GLHModelImporter >> blockEqualityOn: aSymbol [
1✔
57
        ^ [ :existing :new |
1✔
58
          (existing perform: aSymbol) = (new perform: aSymbol) ]
1✔
59
]
1✔
60

61
{ #category : 'equality' }
62
GLHModelImporter >> blockForDiffEquality [
1✔
63
        ^ [ :existing :new |
1✔
64
                        existing diffString size = new diffString size and: [
1✔
65
                                existing diffString = new diffString ] ]
1✔
66
]
1✔
67

68
{ #category : 'equality' }
69
GLHModelImporter >> blockOnIdEquality [
1✔
70

1✔
71
        ^ [ :existing :new |
1✔
72
          existing id = new id ]
1✔
73
]
1✔
74

75
{ #category : 'equality' }
76
GLHModelImporter >> blockOnNameEquality [
1✔
77

1✔
78
        ^ self blockEqualityOn: #name
1✔
79
]
1✔
80

NEW
81
GLHModelImporter >> chainsCommitsFrom: commitsCollection [
×
82

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

×
90
        commitsCollection do: [ :commit |
×
91
                commit parent_ids do: [ :parentId | 
×
92
                        dic
×
93
                                at: parentId
×
94
                                ifPresent: [ :parentCommit |
×
95
                                        parentCommit childCommits
×
96
                                                add: commit
×
97
                                                unless: self blockOnIdEquality ]
×
98
                                ifAbsent: [  ] ] ].
×
99
        ^ commitsCollection
×
100
]
×
101

102

103
{ #category : 'private - api' }
104
GLHModelImporter >> completeImportProject: aGLHProject [
1✔
105

1✔
106
        | importedProject |
1✔
107
        ('Complete import of project: ' , aGLHProject id printString)
1✔
108
                recordInfo.
1✔
109
        aGLHProject repository ifNotNil: [ ^ aGLHProject ].
1✔
110

1✔
111
        importedProject := self glhModel
1✔
112
                                   add: aGLHProject
1✔
113
                                   unless: self blockOnIdEquality.
1✔
114

1✔
115
        self importPipelinesOfProject: importedProject.
1✔
116

1✔
117
        "aGLHProject creator: (self importUser: aGLHProject creator_id)."
1✔
118

1✔
119
        (self importUser: importedProject creator_id) addCreatedProject:
1✔
120
                importedProject.
1✔
121

1✔
122

1✔
123
        importedProject repository: GLHRepository new.
1✔
124
        self glhModel add: importedProject repository.
1✔
125
        self importRepository: importedProject repository.
1✔
126

1✔
127
        ^ importedProject
1✔
128
]
1✔
129

130
{ #category : 'as yet unclassified' }
131
GLHModelImporter >> completeImportedCommit: aCommit [
×
132

×
133
        ('completing commit: ' , aCommit short_id printString) recordInfo.
×
134
        self importCreatorOfCommit: aCommit.
×
135

×
136
        self withCommitDiffs ifTrue: [
×
137
                | diffs |
×
138
                aCommit diffs ifEmpty: [
×
139
                        diffs := self importDiffOfCommit: aCommit.
×
140
                        self glhModel addAll: diffs unless: self blockForDiffEquality ] ].
×
141

×
142
        ^ aCommit
×
143
]
×
144

145

146
{ #category : #'private - configure reader' }
147
GLHModelImporter >> configureReaderForCommit: reader [
1✔
148

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

1✔
164
        reader for: DateAndTime customDo: [ :mapping |
1✔
165
                mapping decoder: [ :string | DateAndTime fromString: string ] ].
1✔
166

1✔
167
        reader
1✔
168
                for: #ArrayOfIds
1✔
169
                customDo: [ :mapping | mapping decoder: [ :string | string ] ].
1✔
170
  
1✔
171
        reader
1✔
172
                for: #ArrayOfCommit
1✔
173
                customDo: [ :customMappting |
1✔
174
                customMappting listOfElementSchema: GLHCommit ].
1✔
175

1✔
176
]
1✔
177

178

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

1✔
182
        reader for: GLHDiff do: [ :mapping |
1✔
183
                mapping mapInstVars:
1✔
184
                        #( deleted_file new_file new_path old_path renamed_file ).
1✔
185
                mapping mapInstVar: #diffString to: #diff ].
1✔
186

1✔
187
        reader
1✔
188
                for: #ArrayOfDiffs
1✔
189
                customDo: [ :customMappting |
1✔
190
                customMappting listOfElementSchema: GLHDiff ].
1✔
191
        ^ reader
1✔
192
]
1✔
193

194

195
{ #category : #'private - configure reader' }
196
GLHModelImporter >> configureReaderForGroup: reader [
1✔
197

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

212
{ #category : 'private' }
213
GLHModelImporter >> convertApiFileAsFile: aAPIFile [
×
214

×
215
        aAPIFile type = 'tree' ifTrue: [ 
×
216
                ^ GLHFileDirectory new
×
217
                          name: aAPIFile name;
×
218
                          yourself ].
×
219
        ^ GLHFileBlob new
×
UNCOV
220
                  name: aAPIFile name;
×
NEW
221
                  yourself
×
222
]
×
223

224
{ #category : 'as yet unclassified' }
225
GLHModelImporter >> detectEntityType: aType overAttribut: aSelector equalTo: value [
×
226

×
UNCOV
227
        ^ (self glhModel allWithType: aType) detect: [ :entity |
×
NEW
228
                  (entity perform: aSelector) = value ] ifNone: [ nil ]. 
×
UNCOV
229
]
×
230

231
{ #category : 'as yet unclassified' }
232
GLHModelImporter >> filterCommitChanges: aCollection [
1✔
233

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

242
{ #category : 'accessing' }
243
GLHModelImporter >> glhApi [
1✔
244

1✔
245
        ^ glhApi
1✔
246
]
1✔
247

248
{ #category : 'accessing' }
249
GLHModelImporter >> glhApi: anObject [
1✔
250

1✔
251
        glhApi := anObject
1✔
252
]
1✔
253

254
{ #category : #accessing }
255
GLHModelImporter >> glhModel [
1✔
256

1✔
257
        ^ glhModel
1✔
258
]
1✔
259

260
{ #category : #accessing }
261
GLHModelImporter >> glhModel: anObject [
1✔
262

1✔
263
        glhModel := anObject
1✔
264
]
1✔
265

266
{ #category : #'as yet unclassified' }
267
GLHModelImporter >> importActiveHumanUsers [
×
268

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

×
284
                newlyFoundUser := self parseUsersResult: results.
×
285
                "newlyFoundCommit do: [ :c | c repository: aProject repository ]."
×
286

×
287
                foundUsers addAll:
×
288
                        (self glhModel
×
289
                                 addAll: newlyFoundUser
×
290
                                 unless: self blockOnIdEquality) ].
×
291

×
UNCOV
292

×
NEW
293
        ^ foundUsers
×
UNCOV
294
]
×
295

296

297
{ #category : 'api' }
298
GLHModelImporter >> importAllGroups [
×
299

×
300
        | page foundGroups newlyFoundGroups |
×
301
        page := 0.
×
302
        foundGroups := OrderedCollection new.
×
303
        newlyFoundGroups := { true }.
×
304
        [ newlyFoundGroups isNotEmpty ] whileTrue: [
×
305
                | results |
×
306
                page := page + 1.
×
307
                results := self glhApi listGroupsWithTopLevelOnly: true page: page.
×
308

×
309
                newlyFoundGroups := generalReader
×
310
                                            on: results readStream;
×
UNCOV
311
                                            nextAs: #ArrayOfGroups.
×
UNCOV
312
                foundGroups addAll: newlyFoundGroups ].
×
UNCOV
313
        ^ foundGroups
×
314
]
×
315

316

317
{ #category : #'as yet unclassified' }
318
GLHModelImporter >> importAndLoadLatestsCommitsOfProject: aGLHProject [
×
319

×
320
        | commits |
×
321
        self completeImportProject: aGLHProject.
×
UNCOV
322
        commits := self importLastestCommitsOfProject: aGLHProject.
×
UNCOV
323
        commits do: [ :commit | self completeImportedCommit: commit ].
×
324
        self chainsCommitsFrom: commits.
×
325
        ^ commits
×
326
]
×
327

328
{ #category : #'private - api' }
329
GLHModelImporter >> importCommit: aCommitID ofProject: aGLHProject [
×
330

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

346
{ #category : 'as yet unclassified' }
347
GLHModelImporter >> importCommitOfProject: anProject withId: anID [
×
348

×
349
        | commit result |
×
350
        anID ifNil: [ ^ nil ].
×
351

×
352
        ('looking for commit ' , anID printString , ' in project : '
×
353
         , anProject id printString) recordInfo.
×
354

×
355
        commit := (self
×
356
                           detectEntityType: GLHCommit
×
357
                           overAttribut: #id
×
358
                           equalTo: anID) ifNil: [
×
359
                          result := self glhApi commit: anID ofProject: anProject id.
×
360
                          commit := (self parseCommitsResult: '[' , result , ']')
×
361
                                            first.
×
362

×
363
                          self glhModel add: commit unless: self blockOnIdEquality.
×
364
                          commit repository: anProject repository.
×
365

×
366
                          commit ].
×
UNCOV
367

×
NEW
368
        self withCommitDiffs ifTrue: [ self importDiffOfCommit: commit ].
×
UNCOV
369

×
370
        ^ commit
×
371
]
×
372

373

374
{ #category : 'private - api' }
375
GLHModelImporter >> importCommits: aGLHProject [
×
376
        "limited to the last 20 commits"
×
377

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

×
396
        parsedResults do: [ :commit |
×
397
                commit repository: aGLHProject repository ].
×
UNCOV
398

×
NEW
399
        self withCommitDiffs ifTrue: [
×
400
                parsedResults do: [ :commit | self importDiffOfCommit: commit ] ].
×
401
        
×
402
        ^ parsedResults. 
×
403
]
×
404

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

×
410
        | date |
×
411
        date := aCommit created_at asDateAndTime.
×
412

×
UNCOV
413
        ^ self
×
NEW
414
                  importCommitsOfBranch: aCommit branch
×
415
                  forRefName: aCommit branch name
×
416
                  since: date
×
417
                  until: (date + aNumberOfDay day)
×
418
]
×
419

420
{ #category : 'commit' }
421
GLHModelImporter >> importCommitsOProject: aProject since: fromDate until: toDate [
×
422

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

×
448
                newlyFoundCommit := self parseCommitsResult: results.
×
449
                "newlyFoundCommit do: [ :c | c repository: aProject repository ]."
×
450

×
451
                foundCommit addAll: (aProject repository commits
×
UNCOV
452
                        addAll: newlyFoundCommit
×
UNCOV
453
                        unless: self blockOnIdEquality). ].
×
UNCOV
454

×
455

×
456
        ^ self glhModel addAll: foundCommit unless: self blockOnIdEquality
×
457
]
×
458

459

460
{ #category : #commit }
461
GLHModelImporter >> importCommitsOf: aGLHProject withStats: aBoolean until: toDate [
×
462

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

×
490
                newlyFoundCommit := parsedResults reject: [ :commitParsed |
×
491
                                            (toDate isNil or: [
×
492
                                                     commitParsed committed_date
×
493
                                                     < toDate asDateAndTime ]) or: [
×
494
                                                    existingCommits anySatisfy: [ :existingCommit |
×
495
                                                            existingCommit id = commitParsed id ] ] ].
×
496
                aGLHProject mooseModel addAll: newlyFoundCommit.
×
UNCOV
497
                aGLHProject repository commits addAll: newlyFoundCommit ].
×
NEW
498

×
499

×
500
        self withCommitDiffs ifTrue: [
×
501
                aGLHProject repository commits do: [ :commit |
×
502
                        self importDiffOfCommit: commit ] ]
×
503
]
×
504

505
{ #category : 'commit' }
506
GLHModelImporter >> importCommitsOfBranch: aGLHBranch forRefName: refName since: fromDate [
×
UNCOV
507

×
NEW
508
        ^ self
×
509
                  importCommitsOfBranch: aGLHBranch
×
510
                  forRefName: aGLHBranch name
×
511
                  since: fromDate
×
512
                  until: nil
×
513
]
×
514

515
{ #category : 'commit' }
516
GLHModelImporter >> importCommitsOfBranch: aGLHBranch forRefName: refName since: fromDate until: toDate [
×
517

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

×
543
                newlyFoundCommit := self parseCommitsResult: results.
×
544
        aGLHBranch commits
×
545
                        addAll: newlyFoundCommit
×
546
                        unless: self blockOnIdEquality.
×
547
        foundCommit addAll: newlyFoundCommit.  
×
548
                        ].
×
549

×
550
        self glhModel
×
551
                addAll: aGLHBranch commits
×
UNCOV
552
                unless: self blockOnIdEquality.
×
NEW
553

×
554
        "self withCommitDiffs ifTrue: [
×
555
                aGLHBranch commits: [ :commit | self importDiffOfCommit: commit ] ]."
×
556

×
557
        ^ foundCommit
×
558
]
×
559

560
{ #category : 'commit' }
561
GLHModelImporter >> importCommitsOfBranch: aGLHBranch forRefName: refName until: toDate [
×
UNCOV
562

×
NEW
563
        ^ self
×
564
                  importCommitsOfBranch: aGLHBranch
×
565
                  forRefName: aGLHBranch name
×
566
                  since: nil
×
567
                  until: toDate
×
568
]
×
569

570
GLHModelImporter >> importContributedProjectsOfUser: aGLHUser [
×
571

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

×
589
                newlyFoundElmts := self parseArrayOfProject: results.
×
UNCOV
590

×
NEW
591
                foundElmts addAll:
×
NEW
592
                        (self glhModel
×
NEW
593
                                 addAll: newlyFoundElmts
×
NEW
594
                                 unless: self blockOnIdEquality) ].
×
NEW
595
]
×
596

597
{ #category : 'as yet unclassified' }
NEW
598
GLHModelImporter >> importCreatorOfCommit: aCommit [
×
NEW
599
        
×
NEW
600
        remaningProjects := self importProjects: ((foundElmts collect: #id) difference: ((self userCatalogue atId: aGLHUser id) at: #contributedProjects)).
×
NEW
601

×
602
        aGLHUser contributedProjects
×
603
                addAll: (foundElmts, remaningProjects)
×
604
                unless: self blockOnIdEquality.
×
605
                
×
606
        self userCatalogue addUser: aGLHUser withProjects: (aGLHUser contributedProjects collect: #id).
×
607

×
608
        ^ foundElmts
×
609
]
×
610

611
{ #category : #'as yet unclassified' }
612
GLHModelImporter >> importCreatorOfCommit2: aCommit [
×
613

×
UNCOV
614
        aCommit commitCreator ifNil: [                
×
NEW
615
                aCommit commitCreator:
×
616
                        (self importUserByUsername: aCommit author_name) ].
×
UNCOV
617
        self userCatalogue addUser: aCommit commitCreator withProject: aCommit repository project id.
×
UNCOV
618
        ^ aCommit commitCreator
×
UNCOV
619
]
×
620

621
{ #category : 'api' }
622
GLHModelImporter >> importDiffOfCommit: aCommit [
1✔
623

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

1✔
635
        ^ aCommit diffs addAll: diffsResult unless: self blockForDiffEquality.
1✔
636

1✔
637
]
1✔
638

639
{ #category : 'private - api' }
640
GLHModelImporter >> importDirectoryFiles: aDirectoryFile OfBranch: aBranch [
×
641

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

660
{ #category : 'private - api' }
661
GLHModelImporter >> importFilesOfBranch: aBranch [
×
662

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

680
{ #category : 'api' }
681
GLHModelImporter >> importGroup: aGroupID [
1✔
682

1✔
683
        | result groupResult |
1✔
684
        ('Import group: ' , aGroupID printString) recordInfo.
1✔
685

1✔
686
        result := self glhApi group: aGroupID.
1✔
687
        groupResult := self parseGroupResult: result.
1✔
688
        groupResult := self addGroupResultToModel: groupResult.
1✔
689

1✔
690
        groupResult projects do: [ :project |
1✔
691
                self completeImportProject: project ].
1✔
692

1✔
693
        (self subGroupsOf: aGroupID) do: [ :subGroup |
1✔
694
                
1✔
695
                groupResult subGroups
1✔
696
                        add: (self importGroup: subGroup id)
1✔
697
                        unless: self blockOnIdEquality ].
1✔
698
        ^ groupResult
1✔
699
]
1✔
700

701
{ #category : 'api' }
702
GLHModelImporter >> importJobsOf: aPipeline [
×
703

×
704
        | result jobs |
×
705
        result := self glhApi
×
706
                          jobsOfProject: aPipeline project id
×
UNCOV
707
                          ofPipelines: aPipeline id.
×
UNCOV
708
        jobs := self parseJobsResult: result ofProject: aPipeline project.
×
UNCOV
709
        jobs do: [ :job | aPipeline addJob: job ].
×
UNCOV
710
        self glhModel addAll: jobs
×
UNCOV
711

×
UNCOV
712
]
×
713

714

715
{ #category : #'private - api' }
716
GLHModelImporter >> importLastestCommitsOfProject: aGLHProject [
1✔
717
        "limited to the last 50 commits"
1✔
718

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

1✔
737
        aGLHProject repository commits addAll: parsedResults unless: self blockOnIdEquality.
1✔
738
        "parsedResults do: [ :commit |
1✔
739
                commit repository: aGLHProject repository ]."
1✔
740

1✔
741
        self withCommitDiffs ifTrue: [
1✔
742
                parsedResults do: [ :commit | self importDiffOfCommit: commit ] ].
1✔
743

1✔
744
        ^ parsedResults
1✔
745
]
1✔
746

747
{ #category : 'commit' }
748
GLHModelImporter >> importParentCommitsOfCommit: aGLHCommit since: aDate [
×
749

×
750
        | parentsIds commits |
×
751
        commits := OrderedCollection new.
×
752
        aGLHCommit created_at asDateAndTime < aDate asDateAndTime ifTrue: [
×
753
                 
×
754
                ^ commits
×
755
                          add: aGLHCommit;
×
756
                          yourself ].
×
757

×
758
        parentsIds := aGLHCommit parent_ids.
×
759

×
760
        commits addAll: (parentsIds collect: [ :id |
×
761
                         self
×
762
                                 importCommitOfProject: aGLHCommit repository project
×
UNCOV
763
                                 withId: id ]).
×
NEW
764

×
UNCOV
765

×
UNCOV
766
        ^ (commits collect: [ :parentCommit |
×
UNCOV
767
                   self importParentCommitsOfCommit: parentCommit since: aDate ])
×
UNCOV
768
                  flatten
×
UNCOV
769
]
×
770

771
{ #category : 'private - api' }
772
GLHModelImporter >> importPipelinesOfProject: aGLHProject [
1✔
773

1✔
774
        (self pipelinesOf: aGLHProject id) do: [ :pipeline |
1✔
775
                self glhModel add: pipeline unless: self blockOnIdEquality .
1✔
776
                aGLHProject pipelines add: pipeline unless: self blockOnIdEquality]
1✔
777
]
1✔
778

779
{ #category : #projects }
780
GLHModelImporter >> importProject: aProjectID [
×
781

×
782
        | result projectResult |
×
UNCOV
783
        ('Import project with id: ' , aProjectID printString) recordInfo.
×
NEW
784

×
785
        result := self glhApi project: aProjectID.
×
786
        projectResult := self parseProjectResult: result.
×
787

×
788
        ^ self completeImportProject: projectResult
×
UNCOV
789
]
×
790

791
{ #category : 'imports' }
792
GLHModelImporter >> importProjects [
×
793

×
794
        ^ self importProjectsSince: nil
×
UNCOV
795
]
×
796

797
{ #category : 'projects' }
798
GLHModelImporter >> importProjects: aCollectionOfProjectID [
×
799

×
800
        ^ aCollectionOfProjectID collect: [ :id | self importProject: id ]
×
801
]
×
802

803
{ #category : 'imports' }
804
GLHModelImporter >> importProjectsSince: since [
×
805
        "heavy import of all projects"
×
806

×
807
        "copy import from commits"
×
808

×
809
        | newlyFoundProjects page foundProject amount |
×
810
        ('import all Projects since: ' , since printString) recordInfo.
×
811

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

×
822
                results := self glhApi projects: amount since: since page: page.
×
823

×
UNCOV
824
                newlyFoundProjects := self glhModel
×
NEW
825
                                              addAll: (self parseArrayOfProject: results)
×
UNCOV
826
                                              unless: self blockOnIdEquality.
×
UNCOV
827
                foundProject addAll: newlyFoundProjects ].
×
UNCOV
828

×
UNCOV
829
        ^ foundProject
×
UNCOV
830
]
×
831

832
{ #category : 'private - api' }
833
GLHModelImporter >> importRepository: aGLHRepository [
1✔
834

1✔
835
        | resultBranches branches |
1✔
836
        [
1✔
837
        ('import the repository of project ' , aGLHRepository project name)
1✔
838
                recordInfo.
1✔
839

1✔
840
        resultBranches := self glhApi branchesOfRepository:
1✔
841
                                  aGLHRepository project id.
1✔
842
        branches := self parseBranchesResult: resultBranches.
1✔
843

1✔
844
        'import the branches of project ' recordInfo.
1✔
845

1✔
846
        branches := aGLHRepository branches
1✔
847
                            addAll: branches
1✔
848
                            unless: self blockOnNameEquality.
1✔
849
        branches := self glhModel
1✔
850
                            addAll: branches
1✔
851
                            unless: self blockOnNameEquality.
1✔
852

1✔
853

1✔
854
        self withFiles ifTrue: [
1✔
855
                branches do: [ :branch | self importFilesOfBranch: branch ] ] ]
1✔
856
                on: NeoJSONParseError
1✔
857
                do: [
1✔
858
                self inform: aGLHRepository project name , ' has no repository' ]
1✔
859
]
1✔
860

861
{ #category : 'private - api' }
862
GLHModelImporter >> importUser: aUserID [
1✔
863

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

874
{ #category : 'user' }
875
GLHModelImporter >> importUserByUsername: anUsername [
×
876

×
877
        | dicUsername resultUser |
×
878
        dicUsername := ((self glhModel allWithType: GLHUser) collect: [ :user |
×
879
                                user username -> user ]) asSet asDictionary.
×
880

×
881
        dicUsername addAll: self userCatalogue collectUsernames.
×
882

×
883

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

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

×
UNCOV
919
        self userCatalogue addUser: resultUser withName: anUsername.
×
UNCOV
920

×
UNCOV
921
        ^ resultUser
×
UNCOV
922
]
×
923

924
{ #category : 'initialization' }
925
GLHModelImporter >> initReader [
1✔
926

1✔
927
        generalReader := NeoJSONReader new.
1✔
928
        self configureReaderForCommit: generalReader.
1✔
929
        self configureReaderForGroup: generalReader.
1✔
930
        self configureReaderForDiffs: generalReader. 
1✔
931
]
1✔
932

933
{ #category : 'initialization' }
934
GLHModelImporter >> initialize [
1✔
935

1✔
936
        super initialize.
1✔
937
        withCommitDiffs := false.
1✔
938
        withInitialCommits := false.
1✔
939
        withInitialMergeRequest := false.
1✔
940

1✔
941
        withCommitsSince := (Date today - 1 week) asDateAndTime.
1✔
942
        userCatalogue := GLHUserCatalogueV2 new
1✔
943
                                 anImporter: self;
1✔
944
                                 yourself.
1✔
945
        self initReader.
1✔
946

1✔
947
        currentImporter := self
1✔
948
]
1✔
949

950
{ #category : 'importer' }
NEW
951
GLHModelImporter >> loadAllProjectsFromRepositorySoftware [
×
952
        "heavy import that load all the active project inside the model. Only import the project entities"
×
NEW
953
        |projects|
×
954
        
×
UNCOV
955
        projects := self glhApi projects. 
×
NEW
956
]
×
957

UNCOV
958
GLHModelImporter >> makeGlobal [
×
NEW
959
        ^ self makeGlobal: DateAndTime now printString.
×
NEW
960
]
×
961

962
{ #category : #'as yet unclassified' }
NEW
963
GLHModelImporter >> makeGlobal: aLabel [ 
×
NEW
964

×
965
        currentImporter := currentImporter ifNil: [ OrderedDictionary new ].
×
966
        currentImporter at: aLabel put: self. 
×
967
        ^ self
×
968
]
×
969

970

971
{ #category : 'private' }
NEW
972
GLHModelImporter >> newParseCommitResult: result [
×
UNCOV
973

×
UNCOV
974
        generalReader  on: result readStream.
×
UNCOV
975

×
UNCOV
976
        ^ generalReader nextAs: GLHCommit
×
UNCOV
977
]
×
978

979
{ #category : 'private' }
980
GLHModelImporter >> newParseDiffResult: result [
1✔
981

1✔
982
        generalReader on: result readStream.
1✔
983
        ^ generalReader nextAs: #ArrayOfDiffs
1✔
984
]
1✔
985

986
{ #category : 'parsing' }
987
GLHModelImporter >> parseArrayOfProject: arrayOfProjects [
×
988

×
989
        | reader |
×
990
        reader := NeoJSONReader on: arrayOfProjects readStream.
×
991
        reader
×
992
                for: #ArrayOfProjects
×
993
                customDo: [ :customMappting |
×
994
                customMappting listOfElementSchema: GLHProject ].
×
995
        reader for: GLHProject do: [ :mapping |
×
996
                mapping mapInstVar: #name to: #name.
×
UNCOV
997
                mapping mapInstVar: #description to: #description.
×
NEW
998
                mapping mapInstVar: #id to: #id.
×
UNCOV
999
                mapping mapInstVar: #archived to: #archived.
×
UNCOV
1000
                mapping mapInstVar: #web_url to: #html_url.
×
UNCOV
1001
                mapping mapInstVar: #topics to: #topics ].
×
UNCOV
1002
        ^ reader nextAs: #ArrayOfProjects
×
UNCOV
1003
]
×
1004

1005
{ #category : 'private' }
1006
GLHModelImporter >> parseBranchesResult: result [
1✔
1007

1✔
1008
        | reader |
1✔
1009
        reader := NeoJSONReader on: result readStream.
1✔
1010
        reader mapInstVarsFor: GLHBranch.
1✔
1011
        reader
1✔
1012
                for: #ArrayOfBranch
1✔
1013
                customDo: [ :customMappting | 
1✔
1014
                customMappting listOfElementSchema: GLHBranch ].
1✔
1015
        ^ reader nextAs: #ArrayOfBranch
1✔
1016
]
1✔
1017

1018
{ #category : 'private' }
1019
GLHModelImporter >> parseCommitResult: result [
×
1020

×
1021
        | reader |
×
1022
        reader := NeoJSONReader on: result readStream.
×
1023

×
1024
        reader for: GLHCommit do: [ :mapping |
×
1025
                mapping mapInstVars:
×
1026
                        #( id short_id title author_name author_email committer_name
×
1027
                           committer_email message web_url ).
×
1028
                (mapping mapInstVar: #authored_date) valueSchema: DateAndTime.
×
1029
                (mapping mapInstVar: #committed_date) valueSchema: DateAndTime.
×
1030
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
×
1031
                (mapping mapInstVar: #parent_ids) valueSchema: #ArrayOfIds.
×
1032
                mapping
×
1033
                        mapProperty: 'stats'
×
1034
                        getter: [ :el | "Not used" ]
×
1035
                        setter: [ :commit :value |
×
1036
                                commit deletions: (value at: #deletions).
×
1037
                                commit additions: (value at: #additions) ] ].
×
1038

×
1039
        reader for: DateAndTime customDo: [ :mapping |
×
1040
                mapping decoder: [ :string | DateAndTime fromString: string ] ].
×
1041

×
UNCOV
1042
        reader
×
NEW
1043
                for: #ArrayOfIds
×
UNCOV
1044
                customDo: [ :mapping | mapping decoder: [ :string | string ] ].
×
UNCOV
1045

×
UNCOV
1046

×
UNCOV
1047
        ^ reader nextAs: GLHCommit
×
UNCOV
1048
]
×
1049

1050
{ #category : 'private' }
1051
GLHModelImporter >> parseCommitsResult: result [
1✔
1052

1✔
1053
        | reader |
1✔
1054
        reader := NeoJSONReader on: result readStream.
1✔
1055

1✔
1056
          reader for: GLHCommit do: [ :mapping |
1✔
1057
                mapping mapInstVars:
1✔
1058
                        #( id short_id title author_name author_email committer_name
1✔
1059
                           committer_email message web_url ).
1✔
1060
                (mapping mapInstVar: #authored_date) valueSchema: DateAndTime.
1✔
1061
                (mapping mapInstVar: #committed_date) valueSchema: DateAndTime.
1✔
1062
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
1✔
1063
                (mapping mapInstVar: #parent_ids) valueSchema: #ArrayOfIds.
1✔
1064
                mapping
1✔
1065
                        mapProperty: 'stats'
1✔
1066
                        getter: [ :el | "Not used" ]
1✔
1067
                        setter: [ :commit :value |
1✔
1068
                                commit deletions: (value at: #deletions).
1✔
1069
                                commit additions: (value at: #additions) ] ].
1✔
1070

1✔
1071
        reader for: DateAndTime customDo: [ :mapping |
1✔
1072
                mapping decoder: [ :string | DateAndTime fromString: string ] ].
1✔
1073

1✔
1074
        reader
1✔
1075
                for: #ArrayOfIds
1✔
1076
                customDo: [ :mapping | mapping decoder: [ :string | string ] ].
1✔
1077
  
1✔
1078
        reader
1✔
1079
                for: #ArrayOfCommit
1✔
1080
                customDo: [ :customMappting |
1✔
1081
                customMappting listOfElementSchema: GLHCommit ].
1✔
1082

1✔
1083
        ^ reader nextAs: #ArrayOfCommit
1✔
1084
]
1✔
1085

1086
{ #category : #private }
1087
GLHModelImporter >> parseDiffResult: result [
×
1088

×
1089
        | reader |
×
1090
        self
×
1091
                deprecated: 'Use #newParseDiffResult: instead'
×
1092
                on: '28 June 2024'
×
1093
                in:
×
1094
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
×
1095
        reader := NeoJSONReader on: result readStream.
×
1096
        reader for: GLHDiff do: [ :mapping |
×
1097
                mapping mapInstVars:
×
1098
                        #( deleted_file new_file new_path old_path renamed_file ).
×
1099
                mapping mapInstVar: #diffString to: #diff ].
×
UNCOV
1100

×
NEW
1101
        reader
×
1102
                for: #ArrayOfDiffs
×
1103
                customDo: [ :customMappting |
×
1104
                customMappting listOfElementSchema: GLHDiff ].
×
1105
        ^ reader nextAs: #ArrayOfDiffs
×
1106
]
×
1107

1108
{ #category : 'private' }
1109
GLHModelImporter >> parseFileTreeResult: aResult [
×
1110

×
1111
        | reader |
×
1112
        reader := NeoJSONReader on: aResult readStream.
×
UNCOV
1113
        reader mapInstVarsFor: GLHApiFile.
×
NEW
1114
        reader
×
UNCOV
1115
                for: #ArrayOfFile
×
UNCOV
1116
                customDo: [ :customMappting | 
×
UNCOV
1117
                customMappting listOfElementSchema: GLHApiFile ].
×
UNCOV
1118
        ^ reader nextAs: #ArrayOfFile
×
UNCOV
1119
]
×
1120

1121
{ #category : 'private' }
1122
GLHModelImporter >> parseGroupResult: aResult [
1✔
1123

1✔
1124
        | reader |
1✔
1125

1✔
1126
        reader := NeoJSONReader on: aResult readStream.
1✔
1127
        reader for: GLHGroup do: [ :mapping |
1✔
1128
                mapping mapInstVars.
1✔
1129
                (mapping mapInstVar: #projects) valueSchema: #ArrayOfProjects ].
1✔
1130
        reader mapInstVarsFor: GLHProject.
1✔
1131
        reader
1✔
1132
                for: #ArrayOfProjects
1✔
1133
                customDo: [ :customMappting |
1✔
1134
                customMappting listOfElementSchema: GLHProject ].
1✔
1135
        ^ reader nextAs: GLHGroup
1✔
1136
]
1✔
1137

1138
{ #category : 'private' }
1139
GLHModelImporter >> parseJobsResult: result ofProject: aProject [
×
1140

×
1141
        | reader |
×
1142
        reader := NeoJSONReader on: result readStream.
×
1143
        reader for: GLHJob do: [ :mapping |
×
1144
                mapping mapInstVars: #( id allow_failure web_url name ).
×
1145

×
1146
                mapping
×
1147
                        mapProperty: #user
×
1148
                        getter: [ :object | #ignore ]
×
1149
                        setter: [ :object :value |
×
1150
                        object user: (self importUser: (value at: #id)) ].
×
1151

×
1152
                mapping
×
1153
                        mapProperty: #commit
×
1154
                        getter: [ :object | #ignore ]
×
1155
                        setter: [ :object :value |
×
1156
                                value ifNotNil: [
×
1157
                                        object commit:
×
1158
                                                (self importCommit: (value at: #id) ofProject: aProject) ] ].
×
1159

×
1160
                mapping
×
1161
                        mapProperty: #duration
×
1162
                        getter: [ :object | #ignore ]
×
1163
                        setter: [ :object :value |
×
1164
                        value ifNotNil: [ object duration: value seconds ] ] ].
×
UNCOV
1165

×
NEW
1166
        reader
×
UNCOV
1167
                for: #ArrayOfGLHJob
×
UNCOV
1168
                customDo: [ :customMappting |
×
UNCOV
1169
                customMappting listOfElementSchema: GLHJob ].
×
UNCOV
1170
        ^ reader nextAs: #ArrayOfGLHJob
×
UNCOV
1171
]
×
1172

1173
{ #category : 'private' }
1174
GLHModelImporter >> parsePipelinesResult: result [
1✔
1175

1✔
1176
        | reader |
1✔
1177
        
1✔
1178
        (result includesSubstring: '{"message":"40' )ifTrue: [ ^ {  } ].
1✔
1179
        
1✔
1180
        reader := NeoJSONReader on: result readStream.
1✔
1181
        reader mapInstVarsFor: GLHPipeline.
1✔
1182
        reader for: GLHPipeline do: [ :mapping |
1✔
1183
                mapping
1✔
1184
                        mapProperty: #created_at
1✔
1185
                        getter: [ :object | #ignore ]
1✔
1186
                        setter: [ :object :value |
1✔
1187
                        object runDate: (DateAndTime fromString: value) ] ].
1✔
1188
        reader
1✔
1189
                for: #ArrayOfPipelines
1✔
1190
                customDo: [ :customMappting |
1✔
1191
                customMappting listOfElementSchema: GLHPipeline ].
1✔
1192
        ^ reader nextAs: #ArrayOfPipelines
1✔
1193
]
1✔
1194

1195

1196
{ #category : #parsing }
1197
GLHModelImporter >> parseProjectResult: aResult [ 
×
1198
                | reader |
×
NEW
1199
        reader := NeoJSONReader on: aResult readStream.
×
1200
        reader for: GLHProject do: [ :mapping |
×
1201
                mapping mapInstVars. ].
×
1202
"        reader mapInstVarsFor: GLHProject."
×
1203

×
1204
        ^ reader nextAs: GLHProject
×
1205
]
×
1206

×
1207

×
NEW
1208
{ #category : 'private' }
×
1209
GLHModelImporter >> parseSubGroupResult: aResult [
×
1210

×
1211
        | reader |
×
1212
        reader := NeoJSONReader on: aResult readStream.
×
1213
        self configureReaderForGroup: reader.
×
1214
        ^ reader nextAs: #ArrayOfGroups
×
1215
]
×
1216

×
1217
{ #category : 'private' }
×
1218
GLHModelImporter >> parseUserResult: result [
×
1219

×
1220
        | reader |
×
1221
        reader := NeoJSONReader on: result readStream.
×
1222
        reader mapInstVarsFor: GLHUser.
×
1223
        ^ reader nextAs: GLHUser
×
1224
]
×
1225

×
1226

×
1227
{ #category : #private }
×
1228
GLHModelImporter >> parseUsersResult: result [
×
1229

×
1230
        | reader |
×
1231
        reader := NeoJSONReader on: result readStream.
×
1232

×
NEW
1233
        reader mapInstVarsFor: GLHUser.
×
1234

×
1235
        reader
×
1236
                for: #ArrayOfUser
×
1237
                customDo: [ :customMappting |
×
1238
                customMappting listOfElementSchema: GLHUser ].
×
1239

×
1240
        ^ reader nextAs: #ArrayOfUser
×
1241
]
×
NEW
1242

×
1243

×
1244
{ #category : 'private - api' }
×
1245
GLHModelImporter >> pipelinesOf: aProjectID [
×
1246

×
1247
        | result |
×
1248
        ('Search pipelines of: ' , aProjectID printString) recordInfo.
×
NEW
1249
        result := self glhApi pipelinesOfProject: aProjectID.
×
1250
        ^ self parsePipelinesResult: result .
×
1251
]
×
1252

×
1253
{ #category : 'as yet unclassified' }
×
1254
GLHModelImporter >> selectEntityType: aType overAttribut: aSelector equalTo: value [
×
1255

×
1256
        ^ (self glhModel allWithType: aType)
×
1257
                select: [ :entity | (entity perform: aSelector) = value ]
×
1258
]
×
1259

×
1260
{ #category : 'private - api' }
×
1261
GLHModelImporter >> subGroupsOf: aGroupID [
×
1262

×
1263
        | results parsedResult result page |
×
1264
        ('Search subgroup of: ' , aGroupID printString) recordInfo.
×
1265
        results := OrderedCollection new.
×
1266
        page := 0.
×
1267
        
×
1268
        parsedResult := { true }.
×
1269
        [ parsedResult size > 0 ] whileTrue: [ 
×
1270
                result := self glhApi subgroupsOfGroup: aGroupID page: page.
×
1271
                parsedResult := self parseSubGroupResult: result.
×
1272
                results addAll: parsedResult.
×
1273
                                page := page + 1. ].
×
1274
        
×
1275
        ^ results
×
1276
]
×
1277

×
1278
{ #category : #accessing }
×
NEW
1279
GLHModelImporter >> userCatalogue [
×
1280
        ^ userCatalogue 
×
1281
]
×
1282

×
1283
{ #category : #accessing }
×
1284
GLHModelImporter >> userCatalogue: aGLHUserCatalogue [
×
NEW
1285

×
1286
        userCatalogue := aGLHUserCatalogue.
×
1287
        aGLHUserCatalogue anImporter: self. 
×
1288
]
×
1289

×
1290
{ #category : 'accessing' }
×
NEW
1291
GLHModelImporter >> withCommitDiffs [
×
1292

×
1293
        ^ withCommitDiffs
×
1294
]
×
UNCOV
1295

×
UNCOV
1296
{ #category : 'accessing' }
×
UNCOV
1297
GLHModelImporter >> withCommitDiffs: anObject [
×
UNCOV
1298

×
UNCOV
1299
        withCommitDiffs := anObject
×
UNCOV
1300
]
×
UNCOV
1301

×
UNCOV
1302
{ #category : 'accessing' }
×
UNCOV
1303
GLHModelImporter >> withInitialCommits: boolean [
×
UNCOV
1304
        withInitialCommits := boolean 
×
UNCOV
1305
]
×
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