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

moosetechnology / GitProjectHealth / 13374480168

17 Feb 2025 04:13PM UTC coverage: 54.598% (-6.6%) from 61.181%
13374480168

push

github

web-flow
Merge pull request #129 from moosetechnology/renaming-importer

Renaming importer

1063 of 2238 new or added lines in 23 files covered. (47.5%)

954 existing lines in 4 files now uncovered.

9624 of 17627 relevant lines covered (54.6%)

0.55 hits per line

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

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

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

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

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

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

39
{ #category : #private }
UNCOV
40
GLHModelImporter >> chainsCommitsFrom: commitsCollection [
×
UNCOV
41

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

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

61
{ #category : #'import - projects' }
UNCOV
62
GLHModelImporter >> completeImportProject: aGLHProject [
×
UNCOV
63

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

×
UNCOV
69
        importedProject := self glhModel
×
UNCOV
70
                                   add: aGLHProject
×
UNCOV
71
                                   unless: self blockOnIdEquality.
×
UNCOV
72

×
UNCOV
73
        self importPipelinesOfProject: importedProject.
×
UNCOV
74

×
UNCOV
75
        "aGLHProject creator: (self importUser: aGLHProject creator_id)."
×
UNCOV
76

×
UNCOV
77
        (self importUser: importedProject creator_id) addCreatedProject:
×
UNCOV
78
                importedProject.
×
UNCOV
79

×
UNCOV
80

×
UNCOV
81
        importedProject repository: GLHRepository new.
×
UNCOV
82
        self glhModel add: importedProject repository.
×
UNCOV
83
        self importRepository: importedProject repository.
×
UNCOV
84

×
UNCOV
85
        ^ importedProject
×
UNCOV
86
]
×
87

88
{ #category : #'import - commits' }
UNCOV
89
GLHModelImporter >> completeImportedCommit: aCommit [
×
UNCOV
90

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

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

×
UNCOV
100
        ^ aCommit
×
UNCOV
101
]
×
102

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

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

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

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

×
UNCOV
133
]
×
134

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

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

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

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

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

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

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

179
{ #category : #private }
UNCOV
180
GLHModelImporter >> detectEntityType: aType overAttribut: aSelector equalTo: value [
×
UNCOV
181

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

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

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

×
195
        ^ repoApi
×
196
]
×
197

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

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

×
207
        repoApi := anObject
×
208
]
×
209

210
{ #category : #accessing }
UNCOV
211
GLHModelImporter >> glhModel [
×
UNCOV
212

×
UNCOV
213
        ^ glhModel
×
UNCOV
214
]
×
215

216
{ #category : #accessing }
UNCOV
217
GLHModelImporter >> glhModel: anObject [
×
UNCOV
218

×
UNCOV
219
        glhModel := anObject
×
UNCOV
220
]
×
221

222
{ #category : #'import - users' }
223
GLHModelImporter >> importActiveHumanUsers [
×
224

×
225
        | params result users |
×
226
        params := { 
×
227
                #humans -> 'true'.
×
228
                #active -> 'true'.
×
229
                #without_project_bots -> 'true'
×
230
        } asDictionary.
×
231
        result := self repoApi users allWithParams: params.
×
232
        users := (result collect: [ :usersJson | self parseUsersResult: usersJson ]) flattened.
×
233
        
×
234
        self glhModel
×
235
                                 addAll: users
×
236
                                 unless: self blockOnIdEquality.
×
237

×
238
        ^ users
×
239
]
×
240

241
{ #category : #'import - groups' }
242
GLHModelImporter >> importAllGroups [
×
243

×
244
        | params results groups |
×
245
        
×
246
        params := { 
×
247
                        #top_level_only -> 'true'
×
248
        } asDictionary.
×
249
        results := self repoApi groups getAllWithParams: params.
×
250
        
×
251
        groups := (results collect: [ :groupsJson | generalReader
×
252
                                            on: groupsJson readStream;
×
253
                                            nextAs: #ArrayOfGroups. ]) flattened.
×
254
        ^ groups
×
255
]
×
256

257
{ #category : #'import - commits' }
258
GLHModelImporter >> importAndLoadLatestsCommitsOfProject: aGLHProject [
×
259

×
260
        | commits completedProject |
×
261
        completedProject := self completeImportProject: aGLHProject.
×
262
        commits := self importLastestCommitsOfProject: completedProject.
×
263
        commits do: [ :commit | self completeImportedCommit: commit ].
×
264
        self chainsCommitsFrom: commits.
×
265
        ^ commits
×
266
]
×
267

268
{ #category : #'import - commits' }
269
GLHModelImporter >> importCommit: aCommitID ofProject: aGLHProject [
×
270

×
271
        | result parsedResult |
×
272
        (self glhModel allWithType: GLHCommit) asOrderedCollection
×
273
                detect: [ :commit | commit id = aCommitID ]
×
274
                ifFound: [ :commit | ^ commit ].
×
275
        result := self repoApi commits get: aCommitID inProject: aGLHProject id.
×
276
        
×
277
        parsedResult := self parseCommitResult: result.
×
278
        
×
279
        self
×
280
                addCommits: { parsedResult }
×
281
                toRepository: aGLHProject repository.
×
282
        ^ parsedResult
×
283
]
×
284

285
{ #category : #'import - commits' }
UNCOV
286
GLHModelImporter >> importCommitOfProject: anProject withId: anID [
×
UNCOV
287

×
UNCOV
288
        | commit result |
×
UNCOV
289
        anID ifNil: [ ^ nil ].
×
UNCOV
290

×
UNCOV
291
        ('looking for commit ' , anID printString , ' in project : '
×
UNCOV
292
         , anProject id printString) recordInfo.
×
UNCOV
293

×
UNCOV
294
        commit := (self
×
UNCOV
295
                           detectEntityType: GLHCommit
×
UNCOV
296
                           overAttribut: #id
×
UNCOV
297
                           equalTo: anID) ifNil: [
×
UNCOV
298
                          result := self repoApi commits get: anID inProject: anProject id.
×
UNCOV
299
                          commit := (self parseCommitsResult: '[' , result , ']')
×
UNCOV
300
                                            first.
×
UNCOV
301

×
UNCOV
302
                          self glhModel add: commit unless: self blockOnIdEquality.
×
UNCOV
303
                          commit repository: anProject repository.
×
UNCOV
304

×
UNCOV
305
                          commit ].
×
UNCOV
306

×
UNCOV
307
        self withCommitDiffs ifTrue: [ self importDiffOfCommit: commit ].
×
UNCOV
308

×
UNCOV
309
        ^ commit
×
UNCOV
310
]
×
311

312
{ #category : #'import - commits' }
313
GLHModelImporter >> importCommits: aGLHProject [
×
314
        "limited to the last 20 commits"
×
315

×
316
        | results parsedResults params |
×
317
        params := { 
×
318
         #with_stats -> 'true'
×
319
        } asDictionary.
×
320
        results := self repoApi commits getByPage: 1 perPage: 20 inProject: aGLHProject id withParams: params.
×
321
        
×
322
        parsedResults := self parseCommitsResult: results.
×
323
        self glhModel addAll: parsedResults unless: self blockOnIdEquality.
×
324

×
325
        parsedResults do: [ :commit |
×
326
                commit repository: aGLHProject repository ].
×
327

×
328
        self withCommitDiffs ifTrue: [
×
329
                parsedResults do: [ :commit | self importDiffOfCommit: commit ] ].
×
330
        
×
331
        ^ parsedResults. 
×
332
]
×
333

334
{ #category : #'import - commits' }
335
GLHModelImporter >> importCommitsFollowing: aCommit upToDays: aNumberOfDay [
×
336
        "import the 'n' commits of a project starting from an initial 'aCommit' commit. 
×
337
        Lazy import does not import the entities inside the model"
×
338

×
339
        | date |
×
340
        date := aCommit created_at asDateAndTime.
×
341

×
342
        ^ self
×
343
                  importCommitsOfBranch: aCommit branch
×
344
                  forRefName: aCommit branch name
×
345
                  since: date
×
346
                  until: (date + aNumberOfDay day)
×
347
]
×
348

349
{ #category : #commit }
350
GLHModelImporter >> importCommitsOf: aGLHProject withStats: aBoolean until: toDate [
×
351

×
352
        | newlyFoundCommit page |
×
353
        
×
354
        self deprecated: [  ] .
×
355
        
×
356
        page := 0.
×
357
        newlyFoundCommit := { true }.
×
358
        [ newlyFoundCommit isNotEmpty ] whileTrue: [
×
359
                | results parsedResults existingCommits |
×
360
                page := page + 1.
×
361
                ('import commit page ' , page printString) recordInfo.
×
362
                results := self repoApi
×
363
                                   commitsOfProject: aGLHProject id
×
364
                                   forRefName: nil
×
365
                                   since: nil
×
366
                                   until: nil
×
367
                                   path: nil
×
368
                                   author: nil
×
369
                                   all: nil
×
370
                                   with_stats: aBoolean
×
371
                                   firstParent: nil
×
372
                                   order: nil
×
373
                                   trailers: nil
×
374
                                   perPage: 100
×
375
                                   page: page.
×
376
                parsedResults := self parseCommitsResult: results.
×
377
                existingCommits := aGLHProject mooseModel allWithType: GLHCommit.
×
378

×
379
                newlyFoundCommit := parsedResults reject: [ :commitParsed |
×
380
                                            (toDate isNil or: [
×
381
                                                     commitParsed committed_date
×
382
                                                     < toDate asDateAndTime ]) or: [
×
383
                                                    existingCommits anySatisfy: [ :existingCommit |
×
384
                                                            existingCommit id = commitParsed id ] ] ].
×
385
                aGLHProject mooseModel addAll: newlyFoundCommit.
×
386
                aGLHProject repository commits addAll: newlyFoundCommit ].
×
387

×
388

×
389
        self withCommitDiffs ifTrue: [
×
390
                aGLHProject repository commits do: [ :commit |
×
391
                        self importDiffOfCommit: commit ] ]
×
392
]
×
393

394
{ #category : #'import - commits' }
395
GLHModelImporter >> importCommitsOfBranch: aGLHBranch forRefName: refName since: fromDate [
×
396

×
397
        ^ self
×
398
                  importCommitsOfBranch: aGLHBranch
×
399
                  forRefName: aGLHBranch name
×
400
                  since: fromDate
×
401
                  until: nil
×
402
]
×
403

404
{ #category : #'import - commits' }
405
GLHModelImporter >> importCommitsOfBranch: aGLHBranch forRefName: refName since: fromDate until: toDate [
×
406

×
407
        | params result allCommits |
×
408
        params := { 
×
409
          #ref_name -> aGLHBranch name.
×
410
          #since ->  (fromDate ifNotNil: [ fromDate asDate asDateAndTime asString ] ifNil: [ '' ]).
×
411
          #until -> (toDate ifNotNil: [ toDate asDate asDateAndTime asString ] ifNil: [ '' ]). 
×
412

×
413
        } asDictionary.
×
414
        result := self repoApi commits getAllInProject: aGLHBranch repository project id withParams: params.
×
415
        
×
416
        allCommits := (result collect: [ :commitsJson | self parseCommitsResult: commitsJson ]) flattened.
×
417
        
×
418
        aGLHBranch commits
×
419
                        addAll: allCommits
×
420
                        unless: self blockOnIdEquality.
×
421

×
422
        self glhModel
×
423
                addAll: aGLHBranch commits
×
424
                unless: self blockOnIdEquality.
×
425

×
426
        ^ allCommits
×
427
]
×
428

429
{ #category : #'import - commits' }
430
GLHModelImporter >> importCommitsOfBranch: aGLHBranch forRefName: refName until: toDate [
×
431

×
432
        ^ self
×
433
                  importCommitsOfBranch: aGLHBranch
×
434
                  forRefName: aGLHBranch name
×
435
                  since: nil
×
436
                  until: toDate
×
437
]
×
438

439
{ #category : #'import - commits' }
UNCOV
440
GLHModelImporter >> importCommitsOfProject: aProject since: fromDate until: toDate [
×
UNCOV
441

×
UNCOV
442
        | params results allCommits |
×
UNCOV
443
        params := {
×
UNCOV
444
                          (#since
×
UNCOV
445
                           ->
×
UNCOV
446
                           (fromDate
×
UNCOV
447
                                    ifNotNil: [ fromDate asDate asDateAndTime asString ]
×
UNCOV
448
                                    ifNil: [ '' ])).
×
UNCOV
449
                          (#until
×
UNCOV
450
                           ->
×
UNCOV
451
                           (toDate
×
UNCOV
452
                                    ifNotNil: [ toDate asDate asDateAndTime asString ]
×
UNCOV
453
                                    ifNil: [ '' ])).
×
UNCOV
454
                          (#with_stats -> 'true').
×
UNCOV
455
                          (#all -> 'true') } asDictionary.
×
UNCOV
456
        results := self repoApi commits
×
UNCOV
457
                           getAllInProject: aProject id
×
UNCOV
458
                           withParams: params.
×
UNCOV
459

×
UNCOV
460
        allCommits := (results collect: [ :commitsJson |
×
UNCOV
461
                               self parseCommitsResult: commitsJson ]) flattened.
×
UNCOV
462

×
UNCOV
463
        allCommits:= aProject repository commits
×
UNCOV
464
                addAll: allCommits
×
UNCOV
465
                unless: self blockOnIdEquality.
×
UNCOV
466

×
UNCOV
467
        ^ self glhModel addAll: allCommits unless: self blockOnIdEquality
×
UNCOV
468
]
×
469

470
{ #category : #'import - projects' }
UNCOV
471
GLHModelImporter >> importContributedProjectsOfUser: aGLHUser [
×
472

×
473
        | remaningProjects params results projects projectsIds |
×
474
        params := {
×
475
                          (#order_by -> 'last_activity_at').
×
476
                          (#simple -> 'true') } asDictionary.
×
477
        results := self repoApi projects
×
478
                           contributedProjectsOfUser: aGLHUser id
×
479
                           withParams: params.
×
480

×
481
        projectsIds := (results collect: [ :projectsJson |
×
482
                             (NeoJSONReader fromString: projectsJson) collect: [:projectJson | projectJson at: #id ] ]) flattened.
×
483
        
×
484
        projects := self importProjects: projectsIds.
×
485
        remaningProjects := self importProjects:
×
486
                                    ((projects collect: #id) difference:
×
487
                                             ((self userCatalogue atId: aGLHUser id) at:
×
488
                                                      #contributedProjects)).
×
489

×
490

×
491
        aGLHUser contributedProjects
×
492
                addAll: projects , remaningProjects
×
493
                unless: self blockOnIdEquality.
×
494

×
495
        self userCatalogue
×
496
                addUser: aGLHUser
×
497
                withProjects: (aGLHUser contributedProjects collect: #id).
×
498

×
499
        ^ projects
×
500
]
×
501

502
{ #category : #'import - commits' }
UNCOV
503
GLHModelImporter >> importCreatorOfCommit: aCommit [
×
UNCOV
504

×
UNCOV
505
        aCommit commitCreator ifNil: [
×
UNCOV
506
                aCommit commitCreator:
×
UNCOV
507
                        (self importUserByUsername: aCommit author_name) ].
×
UNCOV
508
        self userCatalogue
×
UNCOV
509
                addUser: aCommit commitCreator
×
UNCOV
510
                withProject: aCommit repository project id.
×
UNCOV
511
        ^ aCommit commitCreator
×
UNCOV
512
]
×
513

514
{ #category : #'import - commits' }
UNCOV
515
GLHModelImporter >> importDiffOfCommit: aCommit [
×
UNCOV
516

×
UNCOV
517
        | result diffsResult |
×
UNCOV
518
        aCommit diffs ifNotEmpty: [
×
UNCOV
519
                'Diff already importer: ' , aCommit short_id printString recordInfo.
×
UNCOV
520
                ^ aCommit diffs ].
×
UNCOV
521
        ('Import diff of commit: ' , aCommit short_id printString) recordInfo.
×
UNCOV
522
        
×
UNCOV
523
        result := self repoApi commits diffOf: aCommit id inProject: aCommit repository project id  uniDiff: true.
×
UNCOV
524
        
×
UNCOV
525
        (self isServerError: result) ifTrue: [ ^ {  } ].
×
UNCOV
526
        diffsResult := self newParseDiffResult: result.
×
UNCOV
527

×
UNCOV
528
        ^ aCommit diffs addAll: diffsResult unless: self blockForDiffEquality.
×
UNCOV
529

×
UNCOV
530
]
×
531

532
{ #category : #'import - repositories' }
533
GLHModelImporter >> importDirectoryFiles: aDirectoryFile OfBranch: aBranch [
×
534

×
535
        | result files apiFiles params |
×
536
        params := { 
×
537
                #ref -> aBranch name.
×
538
                #path -> (aDirectoryFile path , '/')
×
539
        } asDictionary.
×
540
        result := self repoApi repositories repositoryTreeOfProject: aBranch repository project id withParams: params.
×
541
                         " treeOfRepository: aBranch repository project id
×
542
                          ofBranch: aBranch name
×
543
                          andPath: aDirectoryFile path , '/'."
×
544
        apiFiles := (result collect: [ :treeJson | self parseFileTreeResult: treeJson ]) flattened.
×
545
        files := apiFiles collect: [ :apiFile |
×
546
                         self convertApiFileAsFile: apiFile ].
×
547
        
×
548
        files do: [ :file |
×
549
                self glhModel add: file.
×
550
                aDirectoryFile addFile: file ].
×
551
        
×
552
        files
×
553
                select: [ :file | file isKindOf: GLHFileDirectory ]
×
554
                thenCollect: [ :file |
×
555
                self importDirectoryFiles: file OfBranch: aBranch ]
×
556
]
×
557

558
{ #category : #'import - repositories' }
559
GLHModelImporter >> importFilesOfBranch: aBranch [
×
560

×
561
        | result files apiFiles params |
×
562
        params := { 
×
563
                #ref -> aBranch name.
×
564
        } asDictionary.
×
565
        
×
566
        result := self repoApi repositories repositoryTreeOfProject: aBranch repository project id withParams: params.
×
567
        
×
568
                          "treeOfRepository: aBranch repository project id
×
569
                          ofBranch: aBranch name
×
570
                          andPath: nil."
×
571
        apiFiles := (result collect: [ :filesJson | self parseFileTreeResult: filesJson  ]) flattened.
×
572
        files := apiFiles collect: [ :apiFile | 
×
573
                         self convertApiFileAsFile: apiFile ].
×
574
        files do: [ :file | 
×
575
                self glhModel add: file.
×
576
                aBranch addFile: file ].
×
577
        files
×
578
                select: [ :file | file isKindOf: GLHFileDirectory ]
×
579
                thenCollect: [ :file | 
×
580
                self importDirectoryFiles: file OfBranch: aBranch ]
×
581
]
×
582

583
{ #category : #'import - groups' }
UNCOV
584
GLHModelImporter >> importGroup: aGroupID [
×
UNCOV
585

×
UNCOV
586
        | result groupResult |
×
UNCOV
587
        ('Import group: ' , aGroupID printString) recordInfo.
×
UNCOV
588

×
UNCOV
589
        result := self repoApi groups get: aGroupID.
×
UNCOV
590
        
×
UNCOV
591
        "group: aGroupID."
×
UNCOV
592
        groupResult := self parseGroupResult: result.
×
UNCOV
593
        groupResult := self addGroupResultToModel: groupResult.
×
UNCOV
594

×
UNCOV
595
        groupResult projects do: [ :project |
×
UNCOV
596
                self completeImportProject: project ].
×
UNCOV
597

×
UNCOV
598
        (self subGroupsOf: aGroupID) do: [ :subGroup |
×
UNCOV
599
                
×
UNCOV
600
                groupResult subGroups
×
UNCOV
601
                        add: (self importGroup: subGroup id)
×
UNCOV
602
                        unless: self blockOnIdEquality ].
×
UNCOV
603
        ^ groupResult
×
UNCOV
604
]
×
605

606
{ #category : #'import - jobs' }
607
GLHModelImporter >> importJobsOf: aPipeline [
×
608

×
609
        | jobs results |
×
610
        results := self repoApi jobs allForPipeline: aPipeline id inProject: aPipeline project id.
×
611
                          "jobsOfProject: aPipeline project id
×
612
                          ofPipelines: aPipeline id."
×
613
        jobs := (results collect: [ :jobsJson | self parseJobsResult: jobsJson ofProject: aPipeline project ]) flattened.
×
614
        jobs do: [ :job | aPipeline addJob: job ].
×
615
        self glhModel addAll: jobs.
×
616
        
×
617
        ^jobs
×
618

×
619
]
×
620

621
{ #category : #'import - commits' }
UNCOV
622
GLHModelImporter >> importLastestCommitsOfProject: aGLHProject [
×
UNCOV
623
        "limited to the last 50 commits"
×
UNCOV
624

×
UNCOV
625
        | results parsedResults params |
×
UNCOV
626
        params := { 
×
UNCOV
627
                #with_stats -> 'true'.
×
UNCOV
628
                #all -> true
×
UNCOV
629
         } asDictionary.
×
UNCOV
630
        results := self repoApi commits getByPage: 1 perPage: 50 inProject: aGLHProject id withParams: params.
×
UNCOV
631

×
UNCOV
632
        parsedResults := self parseCommitsResult: results.
×
UNCOV
633
        parsedResults := self glhModel
×
UNCOV
634
                                 addAll: parsedResults
×
UNCOV
635
                                 unless: self blockOnIdEquality.
×
UNCOV
636

×
UNCOV
637
        aGLHProject repository commits
×
UNCOV
638
                addAll: parsedResults
×
UNCOV
639
                unless: self blockOnIdEquality.
×
UNCOV
640

×
UNCOV
641
        self withCommitDiffs ifTrue: [
×
UNCOV
642
                parsedResults do: [ :commit | self importDiffOfCommit: commit ] ].
×
UNCOV
643

×
UNCOV
644
        ^ parsedResults
×
UNCOV
645
]
×
646

647
{ #category : #'import - commits' }
648
GLHModelImporter >> importParentCommitsOfCommit: aGLHCommit since: aDate [
×
649

×
650
        | parentsIds commits |
×
651
        commits := OrderedCollection new.
×
652
        aGLHCommit created_at asDateAndTime < aDate asDateAndTime ifTrue: [
×
653
                 
×
654
                ^ commits
×
655
                          add: aGLHCommit;
×
656
                          yourself ].
×
657

×
658
        parentsIds := aGLHCommit parent_ids.
×
659

×
660
        commits addAll: (parentsIds collect: [ :id |
×
661
                         self
×
662
                                 importCommitOfProject: aGLHCommit repository project
×
663
                                 withId: id ]).
×
664

×
665

×
666
        ^ (commits collect: [ :parentCommit |
×
667
                   self importParentCommitsOfCommit: parentCommit since: aDate ])
×
668
                  flatten
×
669
]
×
670

671
{ #category : #'imports - pipelines' }
UNCOV
672
GLHModelImporter >> importPipelinesOfProject: aGLHProject [
×
UNCOV
673

×
UNCOV
674
        (self pipelinesOf: aGLHProject id) do: [ :pipeline |
×
UNCOV
675
                self glhModel add: pipeline unless: self blockOnIdEquality .
×
UNCOV
676
                aGLHProject pipelines add: pipeline unless: self blockOnIdEquality]
×
UNCOV
677
]
×
678

679
{ #category : #'import - projects' }
680
GLHModelImporter >> importProject: aProjectID [
×
681

×
682
        | result projectResult |
×
683
        ('Import project with id: ' , aProjectID printString) recordInfo.
×
684

×
685
        result := self repoApi projects get: aProjectID.
×
686
        projectResult := self parseProjectResult: result.
×
687

×
688
        ^ self completeImportProject: projectResult
×
689
]
×
690

691
{ #category : #'import - projects' }
692
GLHModelImporter >> importProjects [
×
693

×
694
        | result projects |
×
695
        ('import all Projects') recordInfo.
×
696

×
697

×
698
        result := self repoApi projects all.
×
699
        projects := (result collect: [ :projectsJson | self parseArrayOfProject: projectsJson ]) flattened.
×
700
        
×
701
        self glhModel addAll: projects unless: self blockOnIdEquality.
×
702

×
703
        ^ projects
×
704
]
×
705

706
{ #category : #'import - projects' }
NEW
707
GLHModelImporter >> importProjects: aCollectionOfProjectID [
×
NEW
708

×
NEW
709

×
NEW
710
        ^ aCollectionOfProjectID collect: [ :id | self importProject: id ]
×
NEW
711
]
×
712

713
{ #category : #imports }
714
GLHModelImporter >> importProjectsSince: since [
×
715
        "heavy import of all projects"
×
716

×
717
        "copy import from commits"
×
718

×
719
        | newlyFoundProjects page foundProject amount |
×
720
        ('import all Projects since: ' , since printString) recordInfo.
×
721

×
722
        "number of projects per page"
×
723
        amount := 100.
×
724
        page := 0.
×
725
        foundProject := OrderedCollection new.
×
726
        newlyFoundProjects := { true }.
×
727
        [ newlyFoundProjects isNotEmpty ] whileTrue: [
×
728
                | results |
×
729
                page := page + 1.
×
730
                ('import projects page #' , page printString) recordInfo.
×
731

×
732
                results := self repoApi projects: amount since: since page: page.
×
733

×
734
                newlyFoundProjects := self glhModel
×
735
                                              addAll: (self parseArrayOfProject: results)
×
736
                                              unless: self blockOnIdEquality.
×
737
                foundProject addAll: newlyFoundProjects ].
×
738
]
×
739

740
{ #category : #'import - repositories' }
741
GLHModelImporter >> importRepository: aGLHRepository [
×
UNCOV
742

×
UNCOV
743
        | resultBranches branches |
×
UNCOV
744
        [
×
UNCOV
745
        ('import the repository of project ' , aGLHRepository project name)
×
UNCOV
746
                recordInfo.
×
UNCOV
747

×
UNCOV
748
        resultBranches := self repoApi branches getAllFromProject: aGLHRepository project id.
×
UNCOV
749
        
×
UNCOV
750
        branches := (resultBranches collect: [ :branchesJson | self parseBranchesResult: branchesJson ]) flattened.
×
UNCOV
751

×
UNCOV
752
        'import the branches of project ' recordInfo.
×
UNCOV
753

×
UNCOV
754
        branches := aGLHRepository branches
×
UNCOV
755
                            addAll: branches
×
UNCOV
756
                            unless: self blockOnNameEquality.
×
UNCOV
757
        branches := self glhModel
×
UNCOV
758
                            addAll: branches
×
UNCOV
759
                            unless: self blockOnNameEquality.
×
UNCOV
760

×
UNCOV
761

×
UNCOV
762
        self withFiles ifTrue: [
×
UNCOV
763
                branches do: [ :branch | self importFilesOfBranch: branch ] ] ]
×
UNCOV
764
                on: NeoJSONParseError
×
UNCOV
765
                do: [
×
UNCOV
766
                self inform: aGLHRepository project name , ' has no repository' ]
×
UNCOV
767
]
×
768

769
{ #category : #'import - users' }
UNCOV
770
GLHModelImporter >> importUser: aUserID [
×
UNCOV
771

×
UNCOV
772
        | result userResult |
×
UNCOV
773
        (self glhModel allWithType: GLHUser)
×
UNCOV
774
                detect: [ :user | user id = aUserID ]
×
UNCOV
775
                ifFound: [ :user | ^ user ].
×
UNCOV
776
        ('Import user: ' , aUserID printString) recordInfo.
×
UNCOV
777
        
×
UNCOV
778
        result := self repoApi users get: aUserID.
×
UNCOV
779
        userResult := self parseUserResult: result.
×
UNCOV
780
        
×
NEW
781
        userResult := self glhModel add: userResult unless: self blockOnIdEquality.
×
NEW
782
        userCatalogue addUser: userResult.
×
NEW
783
        ^ userResult 
×
UNCOV
784
]
×
785

786
{ #category : #'import - users' }
UNCOV
787
GLHModelImporter >> importUserByUsername: anUsername [
×
UNCOV
788

×
UNCOV
789
        | dicUsername resultUser |
×
UNCOV
790
        dicUsername := ((self glhModel allWithType: GLHUser) collect: [ :user |
×
UNCOV
791
                                user username -> user ]) asSet asDictionary.
×
UNCOV
792

×
UNCOV
793
        dicUsername addAll: self userCatalogue collectUsernames.
×
UNCOV
794

×
UNCOV
795

×
UNCOV
796
        resultUser := dicUsername
×
UNCOV
797
                              at: anUsername
×
UNCOV
798
                              ifAbsent: [ "thus we have to import this new user"
×
UNCOV
799
                                      | result userId searchResult params |
×
UNCOV
800
                                      ('Import user with username: '
×
UNCOV
801
                                       , anUsername printString) recordInfo.
×
UNCOV
802
                                      params := { (#search -> anUsername) } asDictionary.
×
UNCOV
803
                                      result := self repoApi users allWithParams: params.
×
UNCOV
804
                                                        
×
UNCOV
805
                                                         "when result is an error"
×
UNCOV
806
                                                         (result isString) ifTrue: [ result := { result } ].
×
UNCOV
807
                                                        
×
UNCOV
808
                                      searchResult := result ifEmpty: [ result ] ifNotEmpty: [(result collect: [ :usersJson |
×
UNCOV
809
                                                               NeoJSONReader fromString: usersJson ]) first].
×
UNCOV
810
                                                         
×
UNCOV
811
                                      (searchResult class = Dictionary and: [
×
UNCOV
812
                                               (searchResult at: #message) includesSubstring:
×
UNCOV
813
                                                       '403 Forbidden' ])
×
UNCOV
814
                                              ifTrue: [ "if the result is an 403 error we fake a new user"
×
UNCOV
815
                                                      self glhModel
×
UNCOV
816
                                                              add: (GLHUser new
×
UNCOV
817
                                                                               username: anUsername;
×
UNCOV
818
                                                                               name: anUsername;
×
UNCOV
819
                                                                               yourself)
×
UNCOV
820
                                                              unless: [ :nu :ou | nu username = ou username ] ]
×
UNCOV
821
                                              ifFalse: [
×
UNCOV
822
                                                      searchResult
×
UNCOV
823
                                                              ifEmpty: [ "results can be empty thus we force a new user with the info we have "
×
UNCOV
824
                                                                      self glhModel
×
UNCOV
825
                                                                              add: (GLHUser new
×
UNCOV
826
                                                                                               username: anUsername;
×
UNCOV
827
                                                                                               name: anUsername;
×
UNCOV
828
                                                                                               yourself)
×
UNCOV
829
                                                                              unless: [ :nu :ou | nu username = ou username ] ]
×
UNCOV
830
                                                              ifNotEmpty: [ "because we may already have the researched user, we look by ID in the model"
×
UNCOV
831
                                                                      userId := searchResult first at: #id.
×
UNCOV
832
                                                                      (self glhModel allWithType: GLHUser)
×
UNCOV
833
                                                                              detect: [ :user | user id = userId ]
×
UNCOV
834
                                                                              ifNone: [ self importUser: userId ] ] ] ].
×
UNCOV
835

×
UNCOV
836
        self userCatalogue addUser: resultUser withName: anUsername.
×
UNCOV
837

×
UNCOV
838
        ^ resultUser
×
UNCOV
839
]
×
840

841
{ #category : #initialization }
UNCOV
842
GLHModelImporter >> initReader [
×
UNCOV
843

×
UNCOV
844
        generalReader := NeoJSONReader new.
×
UNCOV
845
        self configureReaderForCommit: generalReader.
×
UNCOV
846
        self configureReaderForGroup: generalReader.
×
UNCOV
847
        self configureReaderForDiffs: generalReader. 
×
UNCOV
848
]
×
849

850
{ #category : #initialization }
UNCOV
851
GLHModelImporter >> initialize [
×
UNCOV
852

×
UNCOV
853
        super initialize.
×
UNCOV
854
        withCommitDiffs := false.
×
UNCOV
855
        withInitialCommits := false.
×
UNCOV
856
        withInitialMergeRequest := false.
×
UNCOV
857

×
UNCOV
858
        withCommitsSince := (Date today - 1 week) asDateAndTime.
×
UNCOV
859

×
UNCOV
860
        self initReader.
×
UNCOV
861

×
UNCOV
862
]
×
863

864
{ #category : #private }
UNCOV
865
GLHModelImporter >> isServerError: aString [
×
UNCOV
866
        ^ aString = '{"message":"500 Internal Server Error"}'
×
UNCOV
867
]
×
868

869
{ #category : #'import - projects' }
870
GLHModelImporter >> loadAllProjectsFromRepositorySoftware [
×
871
        "heavy import that load all the active project inside the model. Only import the project entities"
×
872
        |projects|
×
873
        
×
874
        projects := self repoApi projects. 
×
875
]
×
876

877
{ #category : #'private - parsing' }
878
GLHModelImporter >> newParseCommitResult: result [
×
879

×
880
        generalReader  on: result readStream.
×
881

×
882
        ^ generalReader nextAs: GLHCommit
×
883
]
×
884

885
{ #category : #'private - parsing' }
UNCOV
886
GLHModelImporter >> newParseDiffResult: result [
×
UNCOV
887

×
UNCOV
888
        generalReader on: result readStream.
×
UNCOV
889
        ^ generalReader nextAs: #ArrayOfDiffs
×
UNCOV
890
]
×
891

892
{ #category : #'private - parsing' }
893
GLHModelImporter >> parseArrayOfProject: arrayOfProjects [
×
894

×
895
        | reader |
×
896
        reader := NeoJSONReader on: arrayOfProjects readStream.
×
897
        reader
×
898
                for: #ArrayOfProjects
×
899
                customDo: [ :customMappting |
×
900
                customMappting listOfElementSchema: GLHProject ].
×
901
        reader for: GLHProject do: [ :mapping |
×
902
                mapping mapInstVar: #name to: #name.
×
903
                mapping mapInstVar: #description to: #description.
×
904
                mapping mapInstVar: #id to: #id.
×
905
                mapping mapInstVar: #archived to: #archived.
×
906
                mapping mapInstVar: #web_url to: #html_url.
×
907
                mapping mapInstVar: #topics to: #topics ].
×
908
        ^ reader nextAs: #ArrayOfProjects
×
909
]
×
910

911
{ #category : #'private - parsing' }
UNCOV
912
GLHModelImporter >> parseBranchesResult: result [
×
UNCOV
913

×
UNCOV
914
        | reader |
×
UNCOV
915
        reader := NeoJSONReader on: result readStream.
×
UNCOV
916
        reader mapInstVarsFor: GLHBranch.
×
UNCOV
917
        reader
×
UNCOV
918
                for: #ArrayOfBranch
×
UNCOV
919
                customDo: [ :customMappting | 
×
UNCOV
920
                customMappting listOfElementSchema: GLHBranch ].
×
UNCOV
921
        ^ reader nextAs: #ArrayOfBranch
×
UNCOV
922
]
×
923

924
{ #category : #'private - parsing' }
925
GLHModelImporter >> parseCommitResult: result [
×
926

×
927
        | reader |
×
928
        reader := NeoJSONReader on: result readStream.
×
929

×
930
        reader for: GLHCommit do: [ :mapping |
×
931
                mapping mapInstVars:
×
932
                        #( id short_id title author_name author_email committer_name
×
933
                           committer_email message web_url ).
×
934
                (mapping mapInstVar: #authored_date) valueSchema: DateAndTime.
×
935
                (mapping mapInstVar: #committed_date) valueSchema: DateAndTime.
×
936
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
×
937
                (mapping mapInstVar: #parent_ids) valueSchema: #ArrayOfIds.
×
938
                mapping
×
939
                        mapProperty: 'stats'
×
940
                        getter: [ :el | "Not used" ]
×
941
                        setter: [ :commit :value |
×
942
                                commit deletions: (value at: #deletions).
×
943
                                commit additions: (value at: #additions) ] ].
×
944

×
945
        reader for: DateAndTime customDo: [ :mapping |
×
946
                mapping decoder: [ :string | DateAndTime fromString: string ] ].
×
947

×
948
        reader
×
949
                for: #ArrayOfIds
×
950
                customDo: [ :mapping | mapping decoder: [ :string | string ] ].
×
951

×
952

×
953
        ^ reader nextAs: GLHCommit
×
954
]
×
955

956
{ #category : #'private - parsing' }
UNCOV
957
GLHModelImporter >> parseCommitsResult: result [
×
UNCOV
958

×
UNCOV
959
        | reader |
×
UNCOV
960
        reader := NeoJSONReader on: result readStream.
×
UNCOV
961

×
UNCOV
962
          reader for: GLHCommit do: [ :mapping |
×
UNCOV
963
                mapping mapInstVars:
×
UNCOV
964
                        #( id short_id title author_name author_email committer_name
×
UNCOV
965
                           committer_email message web_url ).
×
UNCOV
966
                (mapping mapInstVar: #authored_date) valueSchema: DateAndTime.
×
UNCOV
967
                (mapping mapInstVar: #committed_date) valueSchema: DateAndTime.
×
UNCOV
968
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
×
UNCOV
969
                (mapping mapInstVar: #parent_ids) valueSchema: #ArrayOfIds.
×
UNCOV
970
                mapping
×
UNCOV
971
                        mapProperty: 'stats'
×
UNCOV
972
                        getter: [ :el | "Not used" ]
×
UNCOV
973
                        setter: [ :commit :value |
×
UNCOV
974
                                commit deletions: (value at: #deletions).
×
UNCOV
975
                                commit additions: (value at: #additions) ] ].
×
UNCOV
976

×
UNCOV
977
        reader for: DateAndTime customDo: [ :mapping |
×
UNCOV
978
                mapping decoder: [ :string | DateAndTime fromString: string ] ].
×
UNCOV
979

×
UNCOV
980
        reader
×
UNCOV
981
                for: #ArrayOfIds
×
UNCOV
982
                customDo: [ :mapping | mapping decoder: [ :string | string ] ].
×
UNCOV
983
  
×
UNCOV
984
        reader
×
UNCOV
985
                for: #ArrayOfCommit
×
UNCOV
986
                customDo: [ :customMappting |
×
UNCOV
987
                customMappting listOfElementSchema: GLHCommit ].
×
UNCOV
988

×
UNCOV
989
        ^ reader nextAs: #ArrayOfCommit
×
UNCOV
990
]
×
991

992
{ #category : #private }
993
GLHModelImporter >> parseDiffResult: result [
×
994

×
995
        | reader |
×
996
        self
×
997
                deprecated: 'Use #newParseDiffResult: instead'
×
998
                on: '28 June 2024'
×
999
                in:
×
1000
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
×
1001
        reader := NeoJSONReader on: result readStream.
×
1002
        reader for: GLHDiff do: [ :mapping |
×
1003
                mapping mapInstVars:
×
1004
                        #( deleted_file new_file new_path old_path renamed_file ).
×
1005
                mapping mapInstVar: #diffString to: #diff ].
×
1006

×
1007
        reader
×
1008
                for: #ArrayOfDiffs
×
1009
                customDo: [ :customMappting |
×
1010
                customMappting listOfElementSchema: GLHDiff ].
×
1011
        ^ reader nextAs: #ArrayOfDiffs
×
1012
]
×
1013

1014
{ #category : #'private - parsing' }
1015
GLHModelImporter >> parseFileTreeResult: aResult [
×
1016

×
1017
        | reader |
×
1018
        reader := NeoJSONReader on: aResult readStream.
×
1019
        reader mapInstVarsFor: GLHApiFile.
×
1020
        reader
×
1021
                for: #ArrayOfFile
×
1022
                customDo: [ :customMappting | 
×
1023
                customMappting listOfElementSchema: GLHApiFile ].
×
1024
        ^ reader nextAs: #ArrayOfFile
×
1025
]
×
1026

1027
{ #category : #'private - parsing' }
UNCOV
1028
GLHModelImporter >> parseGroupResult: aResult [
×
UNCOV
1029

×
UNCOV
1030
        | reader |
×
UNCOV
1031

×
UNCOV
1032
        reader := NeoJSONReader on: aResult readStream.
×
UNCOV
1033
        reader for: GLHGroup do: [ :mapping |
×
UNCOV
1034
                mapping mapInstVars.
×
UNCOV
1035
                (mapping mapInstVar: #projects) valueSchema: #ArrayOfProjects ].
×
UNCOV
1036
        reader mapInstVarsFor: GLHProject.
×
UNCOV
1037
        reader
×
UNCOV
1038
                for: #ArrayOfProjects
×
UNCOV
1039
                customDo: [ :customMappting |
×
UNCOV
1040
                customMappting listOfElementSchema: GLHProject ].
×
UNCOV
1041
        ^ reader nextAs: GLHGroup
×
UNCOV
1042
]
×
1043

1044
{ #category : #'private - parsing' }
1045
GLHModelImporter >> parseJobsResult: result ofProject: aProject [
×
1046

×
1047
        | reader |
×
1048
        reader := NeoJSONReader on: result readStream.
×
1049
        reader for: GLHJob do: [ :mapping |
×
1050
                mapping mapInstVars: #( id allow_failure web_url name ).
×
1051

×
1052
                mapping
×
1053
                        mapProperty: #user
×
1054
                        getter: [ :object | #ignore ]
×
1055
                        setter: [ :object :value |
×
1056
                        object user: (self importUser: (value at: #id)) ].
×
1057

×
1058
                mapping
×
1059
                        mapProperty: #commit
×
1060
                        getter: [ :object | #ignore ]
×
1061
                        setter: [ :object :value |
×
1062
                                value ifNotNil: [
×
1063
                                        object commit:
×
1064
                                                (self importCommit: (value at: #id) ofProject: aProject) ] ].
×
1065

×
1066
                mapping
×
1067
                        mapProperty: #duration
×
1068
                        getter: [ :object | #ignore ]
×
1069
                        setter: [ :object :value |
×
1070
                        value ifNotNil: [ object duration: value seconds ] ] ].
×
1071

×
1072
        reader
×
1073
                for: #ArrayOfGLHJob
×
1074
                customDo: [ :customMappting |
×
1075
                customMappting listOfElementSchema: GLHJob ].
×
1076
        ^ reader nextAs: #ArrayOfGLHJob
×
1077
]
×
1078

1079
{ #category : #'private - parsing' }
1080
GLHModelImporter >> parsePipelinesResult: result [
×
1081

×
1082
        | reader |
×
1083
        
×
1084
        (result includesSubstring: '{"message":"40' )ifTrue: [ ^ {  } ].
×
1085
        
×
1086
        reader := NeoJSONReader on: result readStream.
×
1087
        reader mapInstVarsFor: GLHPipeline.
×
1088
        reader for: GLHPipeline do: [ :mapping |
×
1089
                mapping
×
1090
                        mapProperty: #created_at
×
1091
                        getter: [ :object | #ignore ]
×
1092
                        setter: [ :object :value |
×
1093
                        object runDate: (DateAndTime fromString: value) ] ].
×
1094
        reader
×
1095
                for: #ArrayOfPipelines
×
1096
                customDo: [ :customMappting |
×
1097
                customMappting listOfElementSchema: GLHPipeline ].
×
1098
        ^ reader nextAs: #ArrayOfPipelines
×
1099
]
×
1100

1101
{ #category : #'private - parsing' }
1102
GLHModelImporter >> parseProjectResult: aResult [ 
×
1103
                | reader |
×
1104
        reader := NeoJSONReader on: aResult readStream.
×
1105
        reader for: GLHProject do: [ :mapping |
×
1106
                mapping mapInstVars. ].
×
1107
"        reader mapInstVarsFor: GLHProject."
×
1108

×
1109
        ^ reader nextAs: GLHProject
×
1110
]
×
1111

×
1112
{ #category : #'private - parsing' }
×
1113
GLHModelImporter >> parseSubGroupResult: aResult [
×
1114

×
1115
        | reader |
×
1116
        reader := NeoJSONReader on: aResult readStream.
×
1117
        self configureReaderForGroup: reader.
×
1118
        ^ reader nextAs: #ArrayOfGroups
×
1119
]
×
1120

×
1121
{ #category : #'private - parsing' }
×
1122
GLHModelImporter >> parseUserResult: result [
×
1123

×
1124
        | reader |
×
1125
        reader := NeoJSONReader on: result readStream.
×
1126
        reader mapInstVarsFor: GLHUser.
×
1127
        ^ reader nextAs: GLHUser
×
1128
]
×
1129

×
1130
{ #category : #'private - parsing' }
×
1131
GLHModelImporter >> parseUsersResult: result [
×
1132

×
1133
        | reader |
×
1134
        reader := NeoJSONReader on: result readStream.
×
1135

×
1136
        reader mapInstVarsFor: GLHUser.
×
1137

×
1138
        reader
×
1139
                for: #ArrayOfUser
×
1140
                customDo: [ :customMappting |
×
1141
                customMappting listOfElementSchema: GLHUser ].
×
1142

×
1143
        ^ reader nextAs: #ArrayOfUser
×
1144
]
×
1145

×
1146
{ #category : #'imports - pipelines' }
×
1147
GLHModelImporter >> pipelinesOf: aProjectID [
×
1148

×
1149
        | result |
×
1150
        ('Search pipelines of: ' , aProjectID printString) recordInfo.
×
1151
        result := self repoApi pipelines getAllInProject: aProjectID.
×
NEW
1152
        result isString ifTrue: [ ^ self parsePipelinesResult: result ].
×
NEW
1153

×
NEW
1154
        ^ (result collect: [ :pipelinesJson |
×
NEW
1155
                           self parsePipelinesResult: pipelinesJson ]) flattened
×
1156
]
×
1157

×
1158
{ #category : #private }
×
1159
GLHModelImporter >> selectEntityType: aType overAttribut: aSelector equalTo: value [
×
1160

×
1161
        ^ (self glhModel allWithType: aType)
×
1162
                select: [ :entity | (entity perform: aSelector) = value ]
×
1163
]
×
1164

×
1165
{ #category : #'import - groups' }
×
1166
GLHModelImporter >> subGroupsOf: aGroupID [
×
1167

×
1168
        | results subgroups |
×
1169
        ('Search subgroup of: ' , aGroupID printString) recordInfo.
×
1170
        results := self repoApi groups subgroupsOf: aGroupID.
×
1171
        subgroups := (results collect: [ :subgroupsJson | self parseSubGroupResult: subgroupsJson ]) flattened.
×
1172
        
×
1173
        ^ subgroups
×
1174
]
×
1175

×
1176
{ #category : #accessing }
×
1177
GLHModelImporter >> withInitialCommits: boolean [
×
1178
        withInitialCommits := boolean 
×
1179
]
×
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