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

moosetechnology / GitProjectHealth / 10664257731

02 Sep 2024 09:11AM UTC coverage: 18.06%. First build
10664257731

Pull #46

github

web-flow
Merge f972c3087 into 3d150934d
Pull Request #46: refactor: change metric structure

0 of 840 new or added lines in 23 files covered. (0.0%)

1590 of 8804 relevant lines covered (18.06%)

0.18 hits per line

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

0.0
/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st
1
Class {
2
        #name : #GitMetric4User,
3
        #superclass : #GitMetric,
4
        #instVars : [
5
                'itsCommits',
6
                'itsMergeRequests',
7
                'emailDomain'
8
        ],
9
        #category : #'GitLabHealth-Model-Analysis'
10
}
11

12
{ #category : #churn }
13
GitMetric4User >> foundSuccessorOf: userCommits andCompleteImportForMax: commitLimit [
×
14

×
NEW
15
        | analyzingCommits i size |
×
16
        analyzingCommits := Set new.
×
17
        glhImporter withCommitDiffs: true.
×
18

×
19
        userCommits do: [ :c |
×
NEW
20
                GitAnalyzer new
×
21
                        visitChildCommits: c childCommits
×
22
                        toStoreThemIn: analyzingCommits
×
23
                        upto: commitLimit ].
×
24

×
25
        i := 0.
×
NEW
26
        size := analyzingCommits size.
×
27
        analyzingCommits do: [ :c |
×
NEW
28
                ('import complete commits  [' , (i := i + 1) printString , '/'
×
NEW
29
                 , size printString , ']') recordInfo.
×
30
                glhImporter completeImportedCommit: c ].
×
31

×
32
        ^ analyzingCommits
×
33
]
×
34

35
{ #category : #initialization }
36
GitMetric4User >> initialize [
×
37

×
38
        user := GLHUser new.
×
39
        itsCommits := Dictionary new.
×
40
        itsMergeRequests := Dictionary new.
×
NEW
41

×
42
        emailDomain := '@generic-domain.com'
×
43
]
×
44

45
{ #category : #accessing }
46
GitMetric4User >> itsProjects: projects [
×
47
        itsProjects := projects .
×
48
]
×
49

50
{ #category : #churn }
51
GitMetric4User >> loadCommitOfProjects: aCollection since: aTimespan [
×
52
        |commits|
×
53
        
×
54
        commits := (aCollection collect: [ :id |
×
55
                 glhImporter
×
56
                        importCommitsOProject: (itsProjects at: id)
×
57
                        since: aTimespan
×
58
                        until: nil ]) flattened.
×
59

×
60
        commits do: [ :commit |
×
61
                glhImporter completeImportedCommit: commit. 
×
62
                 ].
×
63

×
64
        ^ self userCommits.
×
65
]
×
66

67
{ #category : #loading }
NEW
68
GitMetric4User >> loadCommitsSince: since until: until [
×
69

×
NEW
70
        | cacheSymbol allCommits userCommits |
×
NEW
71
        itsProjects ifNil: [ self loadProjects ].
×
72

×
73
        glhImporter withCommitDiffs: false.
×
74

×
NEW
75
        cacheSymbol := self
×
NEW
76
                               cacheSymbolFor: GLHCommit
×
NEW
77
                               since: since
×
NEW
78
                               until: until.
×
79

×
NEW
80
        "download commits unless project cache is not empty"
×
NEW
81
        allCommits := itsProjects collect: [ :project |
×
NEW
82
                              project repository cacheAt: cacheSymbol ifAbsentPut: [
×
NEW
83
                                      | foundCommits |
×
NEW
84
                                      foundCommits := glhImporter
×
NEW
85
                                                              importCommitsOProject: project
×
NEW
86
                                                              since: since
×
NEW
87
                                                              until: until.
×
NEW
88
                                      foundCommits ] ].
×
NEW
89

×
NEW
90
        allCommits := allCommits flatten.
×
NEW
91
        allCommits do: [ :commit | glhImporter importCreatorOfCommit: commit ].
×
NEW
92
        glhImporter chainsCommitsFrom: allCommits.
×
NEW
93
        glhImporter withCommitDiffs: true.
×
94

×
NEW
95
        ^ userCommits := allCommits reject: [ :commit |
×
NEW
96
                                 commit commitCreator ~= user ]
×
97
]
×
98

99
{ #category : #loading }
NEW
100
GitMetric4User >> loadCompleteCommitsSince: since until: until [
×
101

×
NEW
102
        | commits |
×
NEW
103
        commits := self loadCommitsSince: since until: until.
×
NEW
104
        commits do: [ :commit | glhImporter completeImportedCommit: commit ].
×
NEW
105
        ^commits
×
NEW
106
        
×
NEW
107
         
×
108
]
×
109

110
{ #category : #loading }
NEW
111
GitMetric4User >> loadCompleteMergeRequestsSince: since until: until [
×
112

×
NEW
113
        | mergeRequests |
×
NEW
114
        mergeRequests := self loadMergeRequestsSince: since until: until.
×
115

×
NEW
116
        mergeRequests do: [ :mergeRequest |
×
NEW
117
                glhImporter importMergeResquestMerger: mergeRequest ].
×
NEW
118
        
×
NEW
119
        ^mergeRequests
×
120
]
×
121

122
{ #category : #loading }
NEW
123
GitMetric4User >> loadMergeRequestsSince: since until: until [
×
NEW
124
        
×
NEW
125
        | cacheSymbol mergeRequests userMergeRequests |
×
NEW
126
        itsProjects ifNil: [ self loadProjects ].
×
NEW
127
        glhImporter withCommitDiffs: false.
×
NEW
128
        cacheSymbol := self
×
NEW
129
                               cacheSymbolFor: GLPHEMergeRequest
×
NEW
130
                               since: since
×
NEW
131
                               until: until.
×
132

×
NEW
133
        mergeRequests := itsProjects collect: [ :project |
×
NEW
134
                                 | mr |
×
NEW
135
                                 project cacheAt: cacheSymbol ifAbsentPut: [
×
NEW
136
                                         mr := glhImporter
×
NEW
137
                                                       importMergeRequests: project
×
NEW
138
                                                       since: since
×
NEW
139
                                                       until: until.
×
NEW
140
                                         mr ] ].
×
141

×
NEW
142
        mergeRequests := mergeRequests flattened.
×
NEW
143
        glhImporter withCommitDiffs: true.
×
144

×
NEW
145
        mergeRequests do: [ :mr | glhImporter importMergeResquestAuthor: mr ].
×
146

×
NEW
147
        userMergeRequests := mergeRequests select: [ :mergeRequest |
×
NEW
148
                                     mergeRequest author = user ].
×
NEW
149
        ^ userMergeRequests
×
150
]
×
151

152
{ #category : #loading }
NEW
153
GitMetric4User >> loadMergeRequestsWithJiraIssueSince: since until: until [
×
154

×
NEW
155
        | email |
×
NEW
156
        itsMergeRequests := self loadMergeRequestsSince: since until: until.
×
157

×
NEW
158
        email := self userEmail.
×
159

×
NEW
160
        jiraImporter importAllCurrentAndPastIssuesOf: email.
×
161

×
NEW
162
        GPJCConnector new
×
NEW
163
                gpModel: glhImporter glhModel;
×
NEW
164
                jiraModel: jiraImporter model;
×
NEW
165
                connect.
×
166

×
NEW
167
        ^ itsMergeRequests select: [ :mergeRequest |
×
NEW
168
                  mergeRequest jiraIssue isNotNil ]
×
169
]
×
170

171
{ #category : #loading }
NEW
172
GitMetric4User >> loadProjects [
×
173

×
NEW
174
        itsProjects ifNotNil: [ ^ itsProjects ].
×
175

×
NEW
176
        itsProjects := glhImporter importContributedProjectsOfUser: user.
×
177

×
NEW
178
        itsProjects do: [ :project |
×
NEW
179
                glhImporter completeImportProject: project ].
×
180

×
NEW
181
        ^ itsProjects
×
182
]
×
183

184
{ #category : #accessing }
185
GitMetric4User >> user [
×
186
        ^ user
×
187
]
×
188

189
{ #category : #accessing }
190
GitMetric4User >> user: anUser [
×
191
        user := anUser. 
×
192
]
×
193

194
{ #category : #accessing }
195
GitMetric4User >> userCommits [
×
196
        ^ user commits
×
197
]
×
198

199
{ #category : #email }
200
GitMetric4User >> userEmail [
×
201
        "overide this method to adapt on your situation"
×
202
 
×
203
        ^ ('' join: {
×
204
                                  user username.
×
205
                                  emailDomain }) asLowercase.
×
206
]
×
207

208
{ #category : #email }
209
GitMetric4User >> withUserEmailDomain: aEmailDomain [
×
210
        emailDomain :=  aEmailDomain. 
×
211
]
×
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