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

moosetechnology / GitProjectHealth / 13372773799

17 Feb 2025 02:41PM UTC coverage: 62.03%. Remained the same
13372773799

Pull #130

github

web-flow
Merge 08e63bd1f into 8ff2bbfd9
Pull Request #130: create w new metric class

1464 of 2739 new or added lines in 38 files covered. (53.45%)

3 existing lines in 3 files now uncovered.

9624 of 15515 relevant lines covered (62.03%)

0.62 hits per line

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

43.3
/src/GitLabHealth-Model-Analysis/GLHUserCatalogue.class.st
1
Class {
2
        #name : #GLHUserCatalogue,
3
        #superclass : #Dictionary,
4
        #instVars : [
5
                'users',
6
                'anImporter'
7
        ],
8
        #category : #'GitLabHealth-Model-Analysis'
9
}
10

11
{ #category : #import }
12
GLHUserCatalogue class >> loadFromJson: aString [
1✔
13

1✔
14
        | catalogue dic |
1✔
15
        catalogue := self new.
1✔
16
        dic := (STONJSON fromString: aString) asDictionary.
1✔
17
        dic associationsDo: [ :assoc |
1✔
18
                | itsName itsUsername itsCommitNames itsId |
1✔
19
                itsName := assoc key.
1✔
20
                itsCommitNames := assoc value at: #foundNames.
1✔
21
                itsUsername := assoc value at: #username.
1✔
22
                itsId := assoc value at: #id.
1✔
23

1✔
24
                catalogue
1✔
25
                        addUser: (GLHUser new
1✔
26
                                         id: itsId;
1✔
27
                                         username: itsUsername;
1✔
28
                                         name: itsName;
1✔
29
                                         yourself)
1✔
30
                        withNames: itsCommitNames ].
1✔
31

1✔
32
        ^ catalogue
1✔
33
]
1✔
34

35
{ #category : #'as yet unclassified' }
NEW
36
GLHUserCatalogue class >> scrapeContributedProjectsForCommitAuthorsRelatedToUser: aGLHUser [
×
NEW
37
        "get all "
×
NEW
38

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

×
NEW
47
        aGLHUser id ifNil: [ ^ {  } asSet ].
×
NEW
48

×
NEW
49
        maxProjects := 10.
×
NEW
50

×
NEW
51
        GLHModelImporter current withCommitDiffs: false.
×
NEW
52
        itsProjects := aGLHUser contributedProjects ifEmpty: [
×
NEW
53
                               GLHModelImporter current
×
NEW
54
                                       importContributedProjectsOfUser: aGLHUser ].
×
NEW
55

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

×
NEW
63
        ^ (aGLHUser commits collect: [ :commit | commit author_name ]) asSet
×
NEW
64
]
×
65

66
{ #category : #'as yet unclassified' }
NEW
67
GLHUserCatalogue class >> scrapeWithImporter: anImporter contributedProjectsForCommitAuthorsRelatedToUser: aGLHUser [
×
NEW
68
        "get all "
×
NEW
69

×
NEW
70
        | maxProjects itsProjects |
×
NEW
71
        aGLHUser id ifNil: [ ^ {  } asSet ].
×
NEW
72

×
NEW
73
        maxProjects := 10.
×
NEW
74

×
NEW
75
        anImporter withCommitDiffs: false.
×
NEW
76
        itsProjects := aGLHUser contributedProjects ifEmpty: [
×
NEW
77
                               anImporter
×
NEW
78
                                       importContributedProjectsOfUser: aGLHUser ].
×
NEW
79

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

×
NEW
87
        ^ (aGLHUser commits collect: [ :commit | commit author_name ]) asSet
×
NEW
88
]
×
89

90
{ #category : #adding }
91
GLHUserCatalogue >> addUser: aGLHUser [
1✔
92

1✔
93
        self at: aGLHUser ifAbsentPut: [ Set new add: (aGLHUser username); add:  (aGLHUser name) ; yourself ]. 
1✔
94
]
1✔
95

96
{ #category : #adding }
97
GLHUserCatalogue >> addUser: aGLHUser withName: name [
1✔
98

1✔
99
        self
1✔
100
                at: aGLHUser
1✔
101
                ifPresent: [ :names | names add: name ]
1✔
102
                ifAbsentPut: [
1✔
103
                        Set new
1✔
104
                                add: aGLHUser username;
1✔
105
                                add: aGLHUser name;
1✔
106
                                add: name;
1✔
107
                                yourself ]
1✔
108
]
1✔
109

110
{ #category : #adding }
111
GLHUserCatalogue >> addUser: aGLHUser withNames: aCollectionOfNames [
1✔
112

1✔
113
        self
1✔
114
                at: aGLHUser
1✔
115
                ifPresent: [ :names | names addAll: aCollectionOfNames ]
1✔
116
                ifAbsentPut: [
1✔
117
                        Set new
1✔
118
                                add: aGLHUser username;
1✔
119
                                add: aGLHUser name;
1✔
120
                                addAll: aCollectionOfNames;
1✔
121
                                yourself ]
1✔
122
]
1✔
123

124
{ #category : #accessing }
NEW
125
GLHUserCatalogue >> anImporter: aGLHModelImporter [
×
NEW
126
        anImporter := aGLHModelImporter
×
NEW
127
        
×
NEW
128
]
×
129

130
{ #category : #accessing }
NEW
131
GLHUserCatalogue >> atWithId: anId [ 
×
NEW
132
        |res |
×
NEW
133
        res := self associations detect: [ :assoc | assoc key id = anId ] ifNone: [ nil ].
×
NEW
134
        ^ res ifNotNil: [ res value ].
×
NEW
135
]
×
136

137
{ #category : #'as yet unclassified' }
138
GLHUserCatalogue >> collectUsernames [
1✔
139

1✔
140
        | username2User |
1✔
141
        self ifEmpty: [ ^ {  } ].
1✔
142

1✔
143
        username2User := OrderedDictionary new.
1✔
144

1✔
145
        self associationsDo: [ :assoc |
1✔
146
                | user |
1✔
147
                user := assoc key.
1✔
148
                assoc value do: [ :username | username2User at: username put: user ] ].
1✔
149

1✔
150
        ^ username2User
1✔
151
]
1✔
152

153
{ #category : #completion }
NEW
154
GLHUserCatalogue >> completeAuthorNameOfUser: aGLHUser with: authorName [
×
NEW
155

×
NEW
156
        self
×
NEW
157
                deprecated: 'Use #addUser:withName: instead'
×
NEW
158
                on: '12 August 2024'
×
NEW
159
                in:
×
NEW
160
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
×
NEW
161

×
NEW
162
        self addUser: aGLHUser withName: authorName
×
NEW
163
]
×
164

165
{ #category : #completion }
NEW
166
GLHUserCatalogue >> completeAuthorNameOfUser: aGLHUser withAll: authorNames [
×
NEW
167

×
NEW
168
        self
×
NEW
169
                deprecated: 'Use #addUser:withNames: instead'
×
NEW
170
                on: '12 August 2024'
×
NEW
171
                in:
×
NEW
172
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
×
NEW
173

×
NEW
174

×
NEW
175
        self addUser: aGLHUser withNames: authorNames
×
NEW
176
]
×
177

178
{ #category : #export }
179
GLHUserCatalogue >> exportToJson [
1✔
180

1✔
181
        | tempDic |
1✔
182
        "        tempDic := self associations collect: [ :assoc |
1✔
183
                                        Dictionary new at: (assoc key name) put: ({
1✔
184
                                   (#names -> assoc value asArray).
1✔
185
                                   (#id -> assoc key id) } asDictionary); yourself ]."
1✔
186
        tempDic := Dictionary new.
1✔
187
        self associationsDo: [ :assoc |
1✔
188
                tempDic
1✔
189
                        at: assoc key name put: {
1✔
190
                                        (#name -> assoc key name).
1✔
191
                                        (#username -> assoc key username).
1✔
192
                                        (#foundNames -> assoc value asArray).
1✔
193
                                        (#id -> assoc key id) } asDictionary;
1✔
194
                        yourself ].
1✔
195

1✔
196
        ^ STONJSON toString: tempDic
1✔
197
]
1✔
198

199
{ #category : #initialization }
NEW
200
GLHUserCatalogue >> initialize [
×
NEW
201

×
NEW
202
        anImporter := GLHModelImporter importers anyOne.
×
NEW
203
]
×
204

205
{ #category : #'as yet unclassified' }
206
GLHUserCatalogue >> namesAt: aGLHUser [
1✔
207

1✔
208
        | assoc |
1✔
209
        assoc := self associationAt: aGLHUser.
1✔
210
        ^ assoc value
1✔
211
]
1✔
212

213
{ #category : #'as yet unclassified' }
NEW
214
GLHUserCatalogue >> reImportAllUsers [
×
NEW
215
        "use it after a catalogue import from JSON"
×
NEW
216

×
NEW
217
        self associationsDo: [ :assoc |
×
NEW
218
                | user |
×
NEW
219
                user := assoc key.
×
NEW
220
                user := anImporter ifNotNil: [
×
NEW
221
                                          user id ifNotNil: [ anImporter importUser: user id ] ifNil: [ anImporter importUserByUsername: user username ]
×
NEW
222
                                 ] ifNil: user.
×
NEW
223
                assoc key: user ]
×
NEW
224
]
×
225

226
{ #category : #'as yet unclassified' }
NEW
227
GLHUserCatalogue >> scrapeAuthorNameForAllUsers [
×
NEW
228

×
NEW
229
        | currentUsers |
×
NEW
230
        currentUsers := self keys.
×
NEW
231
        currentUsers do: [ :key |
×
NEW
232
                (self at: key) addAll: (GLHUserCatalogue
×
NEW
233
                                 scrapeWithImporter: anImporter  contributedProjectsForCommitAuthorsRelatedToUser: key) ]
×
NEW
234
]
×
235

236
{ #category : #'as yet unclassified' }
NEW
237
GLHUserCatalogue >> scrapeAuthorNameForUser: aGLHUser [
×
NEW
238

×
NEW
239
        | assoc |
×
NEW
240
        assoc := self associationAt: aGLHUser.
×
NEW
241
        assoc value addAll: (GLHUserCatalogue
×
NEW
242
                         scrapeWithImporter: anImporter
×
NEW
243
                                 contributedProjectsForCommitAuthorsRelatedToUser: aGLHUser)
×
NEW
244
]
×
245

246
{ #category : #scrape }
NEW
247
GLHUserCatalogue >> scrapeAuthorNamesForUsers: aUserCollection [ 
×
NEW
248
        
×
NEW
249
        aUserCollection do: [ :aGLHUser |
×
NEW
250
                self scrapeAuthorNameForUser: aGLHUser
×
NEW
251
                 ].
×
NEW
252
]
×
253

254
{ #category : #completion }
NEW
255
GLHUserCatalogue >> searchModelForAuthorNamesOfUser: aGLHUser [ 
×
NEW
256
        |assoc|
×
NEW
257
        assoc := self associationAt: aGLHUser.
×
NEW
258
        assoc value addAll: (aGLHUser commits collect: [:c | c author_name]).
×
NEW
259
        
×
NEW
260
]
×
261

262
{ #category : #search }
263
GLHUserCatalogue >> searchName: aName [
1✔
264

1✔
265
        ^ self select: [ :collectionOfName |
1✔
266
                  (' ' join: collectionOfName) asLowercase  includesSubstring: aName asLowercase ]
1✔
267
]
1✔
268

269
{ #category : #search }
270
GLHUserCatalogue >> searchUserWithName: aName [ 
1✔
271
        ^ (self searchName: aName) keys.
1✔
272
]
1✔
273

274
{ #category : #accessing }
NEW
275
GLHUserCatalogue >> users [
×
NEW
276
        ^ self keys
×
NEW
277
]
×
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