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

moosetechnology / GitProjectHealth / 10880677211

16 Sep 2024 09:01AM UTC coverage: 20.332% (-0.2%) from 20.538%
10880677211

push

github

web-flow
Merge pull request #54 from moosetechnology/metrics-fixing

Metrics fixing

0 of 178 new or added lines in 19 files covered. (0.0%)

18 existing lines in 6 files now uncovered.

1961 of 9645 relevant lines covered (20.33%)

0.2 hits per line

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

1.13
/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 [
×
9

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

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

×
30
        ^ catalogue
×
31
]
×
32

33
{ #category : #'as yet unclassified' }
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' }
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' }
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' }
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 [
×
130

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

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

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

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

152
{ #category : #adding }
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 [
×
160
        |entry|
×
161
        
×
162
        entry := self addUser: aGLHUser withNames: aCollectionOfNames.
×
163
        (entry at: #contributedProjects) addAll: aCollectionOfProjectIDs.
×
164
        ^ entry. 
×
165
        
×
166
]
×
167

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

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

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

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

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

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

×
200
        | username2User |
×
201
        self ifEmpty: [ ^ {  } ].
×
202

×
203
        username2User := OrderedDictionary new.
×
204

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

×
210
        ^ username2User
×
211
]
×
212

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

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

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

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

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

×
234

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

238
{ #category : #export }
239
GLHUserCatalogueV2 >> exportToJson [
×
240

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

×
262
        ^ STONJSON toStringPretty: tempDic
×
263
]
×
264

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

275
{ #category : #'instance creation' }
276
GLHUserCatalogueV2 >> initACatalogueEntryForUser: aGLHUser [.
×
277

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

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

×
NEW
293
        anImporter := GLHModelImporter new.
×
294
]
×
295

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

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

×
310
        ^ matrix.
×
311
]
×
312

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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