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

moosetechnology / GitProjectHealth / 13386686180

18 Feb 2025 08:51AM UTC coverage: 54.598% (-7.4%) from 62.03%
13386686180

Pull #132

github

web-flow
Merge 3ce8c1d16 into 8ff2bbfd9
Pull Request #132: renaming all importer

965 of 2132 new or added lines in 16 files covered. (45.26%)

2104 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 }
UNCOV
13
GLHModelImporter >> addCommits: commitsList toRepository: aProjectRepository [
×
UNCOV
14
        "I take a list of GLHCommit. But some might have been parsed but are already on the model..."
×
UNCOV
15

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

×
UNCOV
18
        | existingCommits newlyFoundCommit |
×
UNCOV
19
        existingCommits := aProjectRepository mooseModel allWithType:
×
UNCOV
20
                                   GLHCommit.
×
UNCOV
21
        newlyFoundCommit := commitsList reject: [ :commitParsed |
×
UNCOV
22
                                    existingCommits anySatisfy: [ :existingCommit |
×
UNCOV
23
                                            existingCommit id = commitParsed id ] ].
×
UNCOV
24
        aProjectRepository mooseModel addAll: newlyFoundCommit.
×
UNCOV
25
        aProjectRepository commits addAll: newlyFoundCommit.
×
UNCOV
26
        ^ newlyFoundCommit
×
UNCOV
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 }
UNCOV
168
GLHModelImporter >> convertApiFileAsFile: aAPIFile [
×
UNCOV
169

×
UNCOV
170
        aAPIFile type = 'tree' ifTrue: [ 
×
UNCOV
171
                ^ GLHFileDirectory new
×
UNCOV
172
                          name: aAPIFile name;
×
UNCOV
173
                          yourself ].
×
UNCOV
174
        ^ GLHFileBlob new
×
UNCOV
175
                  name: aAPIFile name;
×
UNCOV
176
                  yourself
×
UNCOV
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 }
UNCOV
187
GLHModelImporter >> glhApi [
×
UNCOV
188

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

×
UNCOV
195
        ^ repoApi
×
UNCOV
196
]
×
197

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

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

×
UNCOV
207
        repoApi := anObject
×
UNCOV
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' }
UNCOV
223
GLHModelImporter >> importActiveHumanUsers [
×
UNCOV
224

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

×
UNCOV
238
        ^ users
×
UNCOV
239
]
×
240

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

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

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

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

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

×
UNCOV
271
        | result parsedResult |
×
UNCOV
272
        (self glhModel allWithType: GLHCommit) asOrderedCollection
×
UNCOV
273
                detect: [ :commit | commit id = aCommitID ]
×
UNCOV
274
                ifFound: [ :commit | ^ commit ].
×
UNCOV
275
        result := self repoApi commits get: aCommitID inProject: aGLHProject id.
×
UNCOV
276
        
×
UNCOV
277
        parsedResult := self parseCommitResult: result.
×
UNCOV
278
        
×
UNCOV
279
        self
×
UNCOV
280
                addCommits: { parsedResult }
×
UNCOV
281
                toRepository: aGLHProject repository.
×
UNCOV
282
        ^ parsedResult
×
UNCOV
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' }
UNCOV
313
GLHModelImporter >> importCommits: aGLHProject [
×
UNCOV
314
        "limited to the last 20 commits"
×
UNCOV
315

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

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

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

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

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

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

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

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

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

×
UNCOV
388

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

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

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

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

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

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

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

×
UNCOV
426
        ^ allCommits
×
UNCOV
427
]
×
428

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

×
UNCOV
432
        ^ self
×
UNCOV
433
                  importCommitsOfBranch: aGLHBranch
×
UNCOV
434
                  forRefName: aGLHBranch name
×
UNCOV
435
                  since: nil
×
UNCOV
436
                  until: toDate
×
UNCOV
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 [
×
UNCOV
472

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

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

×
UNCOV
490

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

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

×
UNCOV
499
        ^ projects
×
UNCOV
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' }
UNCOV
533
GLHModelImporter >> importDirectoryFiles: aDirectoryFile OfBranch: aBranch [
×
UNCOV
534

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

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

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

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

×
UNCOV
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' }
UNCOV
648
GLHModelImporter >> importParentCommitsOfCommit: aGLHCommit since: aDate [
×
UNCOV
649

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

×
UNCOV
658
        parentsIds := aGLHCommit parent_ids.
×
UNCOV
659

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

×
UNCOV
665

×
UNCOV
666
        ^ (commits collect: [ :parentCommit |
×
UNCOV
667
                   self importParentCommitsOfCommit: parentCommit since: aDate ])
×
UNCOV
668
                  flatten
×
UNCOV
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' }
UNCOV
680
GLHModelImporter >> importProject: aProjectID [
×
UNCOV
681

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

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

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

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

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

×
UNCOV
697

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

×
UNCOV
703
        ^ projects
×
UNCOV
704
]
×
705

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

×
UNCOV
709

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

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

×
UNCOV
717
        "copy import from commits"
×
UNCOV
718

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

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

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

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

740
{ #category : #'import - repositories' }
UNCOV
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
        
×
UNCOV
781
        userResult := self glhModel add: userResult unless: self blockOnIdEquality.
×
UNCOV
782
        userCatalogue addUser: userResult.
×
UNCOV
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' }
UNCOV
870
GLHModelImporter >> loadAllProjectsFromRepositorySoftware [
×
UNCOV
871
        "heavy import that load all the active project inside the model. Only import the project entities"
×
UNCOV
872
        |projects|
×
UNCOV
873
        
×
UNCOV
874
        projects := self repoApi projects. 
×
UNCOV
875
]
×
876

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

×
UNCOV
880
        generalReader  on: result readStream.
×
UNCOV
881

×
UNCOV
882
        ^ generalReader nextAs: GLHCommit
×
UNCOV
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' }
UNCOV
893
GLHModelImporter >> parseArrayOfProject: arrayOfProjects [
×
UNCOV
894

×
UNCOV
895
        | reader |
×
UNCOV
896
        reader := NeoJSONReader on: arrayOfProjects readStream.
×
UNCOV
897
        reader
×
UNCOV
898
                for: #ArrayOfProjects
×
UNCOV
899
                customDo: [ :customMappting |
×
UNCOV
900
                customMappting listOfElementSchema: GLHProject ].
×
UNCOV
901
        reader for: GLHProject do: [ :mapping |
×
UNCOV
902
                mapping mapInstVar: #name to: #name.
×
UNCOV
903
                mapping mapInstVar: #description to: #description.
×
UNCOV
904
                mapping mapInstVar: #id to: #id.
×
UNCOV
905
                mapping mapInstVar: #archived to: #archived.
×
UNCOV
906
                mapping mapInstVar: #web_url to: #html_url.
×
UNCOV
907
                mapping mapInstVar: #topics to: #topics ].
×
UNCOV
908
        ^ reader nextAs: #ArrayOfProjects
×
UNCOV
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' }
UNCOV
925
GLHModelImporter >> parseCommitResult: result [
×
UNCOV
926

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

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

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

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

×
UNCOV
952

×
UNCOV
953
        ^ reader nextAs: GLHCommit
×
UNCOV
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 }
UNCOV
993
GLHModelImporter >> parseDiffResult: result [
×
UNCOV
994

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

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

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

×
UNCOV
1017
        | reader |
×
UNCOV
1018
        reader := NeoJSONReader on: aResult readStream.
×
UNCOV
1019
        reader mapInstVarsFor: GLHApiFile.
×
UNCOV
1020
        reader
×
UNCOV
1021
                for: #ArrayOfFile
×
UNCOV
1022
                customDo: [ :customMappting | 
×
UNCOV
1023
                customMappting listOfElementSchema: GLHApiFile ].
×
UNCOV
1024
        ^ reader nextAs: #ArrayOfFile
×
UNCOV
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' }
UNCOV
1045
GLHModelImporter >> parseJobsResult: result ofProject: aProject [
×
UNCOV
1046

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

×
UNCOV
1136
        reader mapInstVarsFor: GLHUser.
×
UNCOV
1137

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

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

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

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

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

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

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

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

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

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