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

moosetechnology / GitProjectHealth / 11667512120

04 Nov 2024 03:36PM UTC coverage: 59.207% (+0.2%) from 59.01%
11667512120

Pull #105

github

web-flow
Merge 0462ff346 into 3c4574e31
Pull Request #105: fix/add email user to the importer + tests

71 of 82 new or added lines in 3 files covered. (86.59%)

149 existing lines in 35 files now uncovered.

9582 of 16184 relevant lines covered (59.21%)

0.59 hits per line

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

34.55
/src/GitLabHealth-Model-Analysis/GLHUserCatalogueV2.class.st
1
Class {
2
        #name : #GLHUserCatalogueV2,
3
        #superclass : #GLHUserCatalogue,
4
        #category : 'GitLabHealth-Model-Analysis'
5
}
6

7
{ #category : #import }
8
GLHUserCatalogueV2 class >> loadFromJson: aString [
1✔
9

1✔
10
        | catalogue dic |
1✔
11
        catalogue := self new.
1✔
12
        dic := (STONJSON fromString: aString) asDictionary.
1✔
13
        dic associationsDo: [ :assoc |
1✔
14
                | itsName itsUsername itsCommitNames itsId itsProjectIDs|
1✔
15
                itsName := assoc key.
1✔
16
                itsCommitNames := assoc value at: #foundNames.
1✔
17
                itsUsername := assoc value at: #username.
1✔
18
                itsId := assoc value at: #id.
1✔
19
                itsProjectIDs := assoc value at: #contributedProjects ifAbsent: [{}].
1✔
20

1✔
21
                catalogue
1✔
22
                        addUser: (GLHUser new
1✔
23
                                         id: itsId;
1✔
24
                                         username: itsUsername;
1✔
25
                                         name: itsName;
1✔
26
                                         yourself)
1✔
27
                        withNames: itsCommitNames
1✔
28
                        withProjects: itsProjectIDs ].
1✔
29

1✔
30
        ^ catalogue
1✔
31
]
1✔
32

33
{ #category : #'as yet unclassified' }
UNCOV
34
GLHUserCatalogueV2 class >> scrapeContributedProjectsForCommitAuthorsRelatedToUser: aGLHUser [
×
35
        "get all "
×
36

×
37
        | maxProjects itsProjects |
×
38
        self
×
39
                deprecated:
×
40
                'Use #scrapeWithImporter:ContributedProjectsForCommitAuthorsRelatedToUser: instead'
×
41
                on: '12 August 2024'
×
42
                in:
×
43
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
×
44

×
45
        aGLHUser id ifNil: [ ^ {  } asSet ].
×
46

×
47
        maxProjects := 10.
×
48

×
49
        GLHModelImporter current withCommitDiffs: false.
×
50
        itsProjects := aGLHUser contributedProjects ifEmpty: [
×
51
                               GLHModelImporter current
×
52
                                       importContributedProjectsOfUser: aGLHUser ].
×
53

×
54
        itsProjects
×
55
                collect: [ :project |
×
56
                        GLHModelImporter current importAndLoadLatestsCommitsOfProject:
×
57
                                project ]
×
58
                from: 1
×
59
                to: (itsProjects size min: maxProjects).
×
60

×
61
        ^ (aGLHUser commits collect: [ :commit | commit author_name ]) asSet
×
62
]
×
63

64
{ #category : #'as yet unclassified' }
UNCOV
65
GLHUserCatalogueV2 class >> scrapeWithImporter: anImporter contributedProjectsForCommitAuthorsRelatedToUser: aGLHUser [
×
66
        "get all "
×
67

×
68
        | maxProjects itsProjects |
×
69
        aGLHUser id ifNil: [ ^ {  } asSet ].
×
70

×
71
        maxProjects := 10.
×
72

×
73
        anImporter withCommitDiffs: false.
×
74
        itsProjects := aGLHUser contributedProjects ifEmpty: [
×
75
                               anImporter
×
76
                                       importContributedProjectsOfUser: aGLHUser ].
×
77

×
78
        itsProjects
×
79
                collect: [ :project |
×
80
                        anImporter importAndLoadLatestsCommitsOfProject:
×
81
                                project ]
×
82
                from: 1
×
83
                to: (itsProjects size min: maxProjects).
×
84

×
85
        ^ (aGLHUser commits collect: [ :commit | commit author_name ]) asSet
×
86
]
×
87

88
{ #category : #'as yet unclassified' }
UNCOV
89
GLHUserCatalogueV2 >> RSHeatMapLevenshtein [
×
90
        
×
91
                | builder|
×
92
        builder := RSHeatmap new.
×
93
        builder objectsX: self keys.
×
94
        builder objectsY: self keys.
×
95

×
96
        builder dataMatrix: self levenshteinMatrix.
×
97

×
98
        builder build.
×
99
        builder gradientLegend remove.
×
100
        builder canvas open
×
101
]
×
102

103
{ #category : #'as yet unclassified' }
UNCOV
104
GLHUserCatalogueV2 >> RSHeatMapLevenshteinTrimedAt: aBlockCondition [
×
105
        
×
106
                | builder matrice|
×
107
        builder := RSHeatmap new.
×
108
        builder objectsX: self keys.
×
109
        builder objectsY: self keys.
×
110
        
×
111

×
112
        matrice := self levenshteinMatrix.
×
113
        1 to: matrice size do: [ :i |
×
114
                1 to: (matrice at: i) size do: [ :j |
×
115
                        |val|
×
116
                        val := ((matrice at: i) at: j).
×
117
                        (matrice at: i) at: j put: ( aBlockCondition value: val ).
×
118
                         ] ].
×
119
        
×
120
        
×
121
        builder dataMatrix: matrice.
×
122

×
123
        builder build.
×
124
        builder gradientLegend remove.
×
125
        builder canvas open
×
126
]
×
127

128
{ #category : #adding }
129
GLHUserCatalogueV2 >> addUser: aGLHUser [
1✔
130

1✔
131
        ^ self at: aGLHUser name ifAbsentPut: [
1✔
132
                self initACatalogueEntryForUser: aGLHUser ]
1✔
133
]
1✔
134

135
{ #category : #adding }
136
GLHUserCatalogueV2 >> addUser: aGLHUser withName: name [
1✔
137

1✔
138
        ^ self addUser: aGLHUser withNames: { name }
1✔
139
        
1✔
140
]
1✔
141

142
{ #category : #adding }
143
GLHUserCatalogueV2 >> addUser: aGLHUser withNames: aCollectionOfNames [
1✔
144
        | entry |
1✔
145
        entry := (self
1✔
146
                at: aGLHUser name
1✔
147
                ifAbsentPut: [ (self initACatalogueEntryForUser: aGLHUser ). ]).
1✔
148
        (entry  at: #names)  addAll: aCollectionOfNames. 
1✔
149
        ^ entry
1✔
150
]
1✔
151

152
{ #category : #adding }
UNCOV
153
GLHUserCatalogueV2 >> addUser: aGLHUser withNames: aCollectionOfNames withProject: aProjectID [
×
154

×
155
        ^ self addUser: aGLHUser withNames: aCollectionOfNames withProjects: { aProjectID }
×
156
]
×
157

158
{ #category : #adding }
159
GLHUserCatalogueV2 >> addUser: aGLHUser withNames: aCollectionOfNames withProjects: aCollectionOfProjectIDs [
1✔
160
        |entry|
1✔
161
        
1✔
162
        entry := self addUser: aGLHUser withNames: aCollectionOfNames.
1✔
163
        (entry at: #contributedProjects) addAll: aCollectionOfProjectIDs.
1✔
164
        ^ entry. 
1✔
165
        
1✔
166
]
1✔
167

168
{ #category : #adding }
169
GLHUserCatalogueV2 >> addUser: aGLHUser withProject: aProjectID [
1✔
170
        
1✔
171
        ^ self addUser: aGLHUser withProjects: {aProjectID}.
1✔
172
        
1✔
173
]
1✔
174

175
{ #category : #adding }
176
GLHUserCatalogueV2 >> addUser: aGLHUser withProjects: aCollectionOfProjectIDs [
1✔
177
        |entry|
1✔
178

1✔
179
        entry := self addUser: aGLHUser.
1✔
180
        (entry at: #contributedProjects) addAll: aCollectionOfProjectIDs.
1✔
181
        ^ entry.
1✔
182
        
1✔
183
]
1✔
184

185
{ #category : #accessing }
186
GLHUserCatalogueV2 >> anImporter: aGLHModelImporter [
1✔
187
        anImporter := aGLHModelImporter
1✔
188
        
1✔
189
]
1✔
190

191
{ #category : #accessing }
UNCOV
192
GLHUserCatalogueV2 >> atId: anId [ 
×
193
        ^ self detect: [ :entry |
×
194
                (entry at: #user) id =  anId ]
×
195
]
×
196

197
{ #category : #'as yet unclassified' }
198
GLHUserCatalogueV2 >> collectUsernames [
1✔
199

1✔
200
        | username2User |
1✔
201
        self ifEmpty: [ ^ OrderedDictionary new ].
1✔
202

1✔
203
        username2User := OrderedDictionary new.
1✔
204

1✔
205
        self associationsDo: [ :assoc |
1✔
206
                | user |
1✔
207
                user := assoc value at: #user.
1✔
208
                (assoc value at: #names) do: [ :username |
1✔
209
                        username2User at: username put: user ] ].
1✔
210

1✔
211
        ^ username2User
1✔
212
]
1✔
213

214
{ #category : #completion }
UNCOV
215
GLHUserCatalogueV2 >> completeAuthorNameOfUser: aGLHUser with: authorName [
×
216

×
217
        self
×
218
                deprecated: 'Use #addUser:withName: instead'
×
219
                on: '12 August 2024'
×
220
                in:
×
221
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
×
222

×
223
        self addUser: aGLHUser withName: authorName
×
224
]
×
225

226
{ #category : #completion }
UNCOV
227
GLHUserCatalogueV2 >> completeAuthorNameOfUser: aGLHUser withAll: authorNames [
×
228

×
229
        self
×
230
                deprecated: 'Use #addUser:withNames: instead'
×
231
                on: '12 August 2024'
×
232
                in:
×
233
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
×
234

×
235

×
236
        self addUser: aGLHUser withNames: authorNames
×
237
]
×
238

239
{ #category : #export }
240
GLHUserCatalogueV2 >> exportToJson [
1✔
241

1✔
242
        | tempDic |
1✔
243
        "        tempDic := self associations collect: [ :assoc |
1✔
244
                                        Dictionary new at: (assoc key name) put: ({
1✔
245
                                   (#names -> assoc value asArray).
1✔
246
                                   (#id -> assoc key id) } asDictionary); yourself ]."
1✔
247
        tempDic := Dictionary new.
1✔
248
        self associationsDo: [ :assoc |
1✔
249
                |entry user names projectIDs|
1✔
250
                entry := assoc value.
1✔
251
                user := entry at: #user.
1✔
252
                names := entry at: #names.
1✔
253
                projectIDs := entry at: #contributedProjects.
1✔
254
                tempDic
1✔
255
                        at: assoc key put: {
1✔
256
                                        (#name -> user name).
1✔
257
                                        (#username -> user username).
1✔
258
                                        (#foundNames -> names asArray).
1✔
259
                                        (#contributedProjects -> projectIDs asArray).
1✔
260
                                        (#id -> user id) } asDictionary;
1✔
261
                        yourself ].
1✔
262

1✔
263
        ^ STONJSON toStringPretty: tempDic
1✔
264
]
1✔
265

266
{ #category : #fuse }
UNCOV
267
GLHUserCatalogueV2 >> fuse: mainUser with: subUser [ 
×
268
        self at: mainUser ifPresent: [ :entry |
×
269
                self at: subUser ifAbsent: [ ^ self ]. 
×
270
                (entry at: #names) addAll: (self at: subUser at: #names ).
×
271
                (entry at: #contributedProjects) addAll: (self at: subUser at: #contributedProjects ).
×
272
                self removeKey: subUser.
×
273
                 ].
×
274
]
×
275

276
{ #category : #'instance creation' }
277
GLHUserCatalogueV2 >> initACatalogueEntryForUser: aGLHUser [.
1✔
278

1✔
279
^ Dictionary new
1✔
280
                        at: #user put: aGLHUser;
1✔
281
                        at: #names put: (Set new
1✔
282
                                         add: aGLHUser username;
1✔
283
                                         add: aGLHUser name;
1✔
284
                                         yourself);
1✔
285
                        at: #contributedProjects put: (Set new 
1✔
286
                                        addAll: (aGLHUser contributedProjects collect: #id); 
1✔
287
                                        yourself );
1✔
288
                        yourself
1✔
289
]
1✔
290

291
{ #category : #initialization }
UNCOV
292
GLHUserCatalogueV2 >> initialize [
×
293

×
294
        anImporter := GLHModelImporter new.
×
295
]
×
296

297
{ #category : #'as yet unclassified' }
UNCOV
298
GLHUserCatalogueV2 >> levenshteinMatrix [ 
×
299
        | matrix|
×
300

×
301
        matrix := Array new: self keys size .
×
302
        1 to: matrix size do: [ :i | matrix at: i put: (Array new: self keys size) ]. 
×
303
        
×
304
        1 to: self keys size do: [ :i |
×
305
                1 to: self keys size do: [ :j |
×
306
                        
×
307
                        (matrix at: i) at: j put: ( (self keys at: i) absLevenshteinDistanceWith: (self keys at: j) ). 
×
308
                          ].
×
309
                  ].
×
310

×
311
        ^ matrix.
×
312
]
×
313

314
{ #category : #'accessing - name' }
UNCOV
315
GLHUserCatalogueV2 >> names [
×
316
        ^ self collect: [ :entry | entry at: #names ]
×
317
]
×
318

319
{ #category : #'as yet unclassified' }
320
GLHUserCatalogueV2 >> namesAt: aGLHUser [
1✔
321
        ^ (self at: aGLHUser name) at: #names.
1✔
322
]
1✔
323

324
{ #category : #'as yet unclassified' }
UNCOV
325
GLHUserCatalogueV2 >> reImportAllUsers [
×
326
        "use it after a catalogue import from JSON"
×
327

×
328
        self associationsDo: [ :assoc |
×
329
                | user |
×
330
                user := assoc value at: #user.
×
331
                user := anImporter
×
332
                                ifNotNil: [
×
333
                                        user id
×
334
                                                ifNotNil: [ anImporter importUser: user id ]
×
335
                                                ifNil: [ anImporter importUserByUsername: user username ] ]
×
336
                                ifNil: [user].
×
337
                assoc value at: #user put: user ]
×
338
]
×
339

340
{ #category : #'as yet unclassified' }
UNCOV
341
GLHUserCatalogueV2 >> reImportUser: aGLHUser [
×
342
        "use it after a catalogue import from JSON"
×
343
        |user|
×
344
        user := anImporter
×
345
                                ifNotNil: [
×
346
                                        aGLHUser id
×
347
                                                ifNotNil: [ anImporter importUser: aGLHUser id ]
×
348
                                                ifNil: [ anImporter importUserByUsername: aGLHUser username ] ]
×
349
                                ifNil: [aGLHUser].
×
350
        
×
351
        
×
352
        self at: aGLHUser name at: #user put: (user).
×
353
        
×
354
]
×
355

356
{ #category : #scrape }
UNCOV
357
GLHUserCatalogueV2 >> scrapeAuthorNameForAllRealUsers [
×
358
        
×
359
        |listOfUsers|
×
360
        listOfUsers := self users select: [ :user | user id isNotNil ].
×
361
        listOfUsers do: [ :user | self scrapeAuthorNameForUser: user ].
×
362
]
×
363

364
{ #category : #'as yet unclassified' }
UNCOV
365
GLHUserCatalogueV2 >> scrapeAuthorNameForAllUsers [
×
366

×
367
        |listOfUsers|
×
368
        
×
369
        listOfUsers := self users. 
×
370
        listOfUsers do: [ :user | self scrapeAuthorNameForUser: user ]
×
371
]
×
372

373
{ #category : #'as yet unclassified' }
UNCOV
374
GLHUserCatalogueV2 >> scrapeAuthorNameForUser: aGLHUser [
×
375

×
376
        self addUser: aGLHUser withNames: (GLHUserCatalogue
×
377
                         scrapeWithImporter: anImporter
×
378
                         contributedProjectsForCommitAuthorsRelatedToUser: aGLHUser).
×
379
]
×
380

381
{ #category : #scrape }
UNCOV
382
GLHUserCatalogueV2 >> scrapeAuthorNamesForUsers: aUserCollection [ 
×
383
        
×
384
        aUserCollection do: [ :aGLHUser |
×
385
                self scrapeAuthorNameForUser: aGLHUser
×
386
                 ].
×
387
]
×
388

389
{ #category : #search }
UNCOV
390
GLHUserCatalogueV2 >> searchId: anId [ 
×
391
        ^ self select: [ :entry | (entry at: #user) id = anId ].
×
392
]
×
393

394
{ #category : #completion }
UNCOV
395
GLHUserCatalogueV2 >> searchModelForAuthorNamesOfUser: aGLHUser [
×
396

×
397
        self addUser: aGLHUser withNames: 
×
398
                (aGLHUser commits collect: [ :c | c author_name ])
×
399
]
×
400

401
{ #category : #search }
UNCOV
402
GLHUserCatalogueV2 >> searchName: aName [
×
403

×
404
        ^ self select: [ :entry |
×
405
                |collectionOfName|
×
406
                collectionOfName := entry at: #names.
×
407
                  (' ' join: collectionOfName) asLowercase includesSubstring:
×
408
                          aName asLowercase ]
×
409
]
×
410

411
{ #category : #search }
UNCOV
412
GLHUserCatalogueV2 >> searchUserWithName: aName [
×
413

×
414
        ^ (self searchName: aName) users
×
415
]
×
416

417
{ #category : #accessing }
UNCOV
418
GLHUserCatalogueV2 >> userAt: aGLHUser [
×
419
        ^ (self at: aGLHUser name) at: #user.  
×
420
]
×
421

422
{ #category : #accessing }
UNCOV
423
GLHUserCatalogueV2 >> users [
×
424

×
425
        ^ self collect: [ :entry | entry at: #user ].
×
426
]
×
427

428
{ #category : #search }
UNCOV
429
GLHUserCatalogueV2 >> weirdUsers [
×
430
        "return user that have name containing weird caracter, making them suspicious"
×
431
        ^ self select: [ :entry |
×
432
                ((entry at:#user) name includesSubstring: '.') or: [ 
×
433
                        (entry at:#user) name includesSubstring: '@' ]
×
434
                 ].
×
435
]
×
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