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

moosetechnology / GitProjectHealth / 13386705041

18 Feb 2025 08:53AM UTC coverage: 61.942% (-0.09%) from 62.03%
13386705041

Pull #132

github

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

965 of 2138 new or added lines in 18 files covered. (45.14%)

3 existing lines in 1 file now uncovered.

9624 of 15537 relevant lines covered (61.94%)

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' }
36
GLHUserCatalogue class >> scrapeContributedProjectsForCommitAuthorsRelatedToUser: aGLHUser [
×
37
        "get all "
×
38

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

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

×
49
        maxProjects := 10.
×
50

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

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

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

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

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

×
73
        maxProjects := 10.
×
74

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

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

×
87
        ^ (aGLHUser commits collect: [ :commit | commit author_name ]) asSet
×
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 }
125
GLHUserCatalogue >> anImporter: aGLHModelImporter [
×
126
        anImporter := aGLHModelImporter
×
127
        
×
128
]
×
129

130
{ #category : #accessing }
131
GLHUserCatalogue >> atWithId: anId [ 
×
132
        |res |
×
133
        res := self associations detect: [ :assoc | assoc key id = anId ] ifNone: [ nil ].
×
134
        ^ res ifNotNil: [ res value ].
×
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 }
154
GLHUserCatalogue >> completeAuthorNameOfUser: aGLHUser with: authorName [
×
155

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

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

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

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

×
174

×
175
        self addUser: aGLHUser withNames: authorNames
×
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 }
200
GLHUserCatalogue >> initialize [
×
201

×
NEW
202
        anImporter := GitlabModelImporter importers anyOne.
×
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' }
214
GLHUserCatalogue >> reImportAllUsers [
×
215
        "use it after a catalogue import from JSON"
×
216

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

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

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

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

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

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

254
{ #category : #completion }
255
GLHUserCatalogue >> searchModelForAuthorNamesOfUser: aGLHUser [ 
×
256
        |assoc|
×
257
        assoc := self associationAt: aGLHUser.
×
258
        assoc value addAll: (aGLHUser commits collect: [:c | c author_name]).
×
259
        
×
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 }
275
GLHUserCatalogue >> users [
×
276
        ^ self keys
×
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