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

moosetechnology / GitProjectHealth / 10094571032

25 Jul 2024 12:59PM UTC coverage: 31.874% (-0.4%) from 32.312%
10094571032

push

github

web-flow
Merge pull request #9 from moosetechnology/refactoring/metrics-interface

Refactoring/metrics interface

84 of 391 new or added lines in 10 files covered. (21.48%)

13 existing lines in 2 files now uncovered.

2526 of 7925 relevant lines covered (31.87%)

0.32 hits per line

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

0.0
/src/GitLabHealth-Model-Analysis/GitMetric.class.st
1
Class {
2
        #name : #GitMetric,
3
        #superclass : #Object,
4
        #instVars : [
5
                'user',
6
                'glhImporter',
7
                'itsProjects',
8
                'gitAnalyzer',
9
                'glhModel'
10
        ],
11
        #category : #'GitLabHealth-Model-Analysis'
12
}
13

14
{ #category : #setup }
NEW
15
GitMetric class >> setupGroupedDateFrom: since to: until over: aDateWeekMonthOrYear [
×
NEW
16

×
NEW
17
        | groupedByDate start end over increment |
×
NEW
18
        groupedByDate := OrderedDictionary new.
×
NEW
19

×
NEW
20
        increment := 1.
×
NEW
21
        start := self transformDate: since to: aDateWeekMonthOrYear.
×
NEW
22
        end := self transformDate: until to: aDateWeekMonthOrYear.
×
NEW
23

×
NEW
24
        groupedByDate
×
NEW
25
                at: start printString
×
NEW
26
                ifAbsentPut: [ OrderedCollection new ].
×
NEW
27

×
NEW
28
        over := aDateWeekMonthOrYear name asLowercase asSymbol.
×
NEW
29
        over = #date ifTrue: [ over := #day ].
×
NEW
30
        over = #month ifTrue: [
×
NEW
31
                increment := 32.
×
NEW
32
                over := #day ].
×
NEW
33

×
NEW
34

×
NEW
35
        [ groupedByDate keys last asDateAndTime < end ] whileTrue: [
×
NEW
36
                | index |
×
NEW
37
                index := groupedByDate keys last asDateAndTime
×
NEW
38
                         + (increment perform: over).
×
NEW
39
                index := self transformDate: index to: aDateWeekMonthOrYear.
×
NEW
40
                groupedByDate
×
NEW
41
                        at: index printString
×
NEW
42
                        ifAbsentPut: [ OrderedCollection new ] ].
×
NEW
43

×
NEW
44

×
NEW
45
        over = #day ifTrue: [
×
NEW
46
                groupedByDate keysDo: [ :date |
×
NEW
47
                        | aWeekday |
×
NEW
48
                        aWeekday := date asDate weekday.
×
NEW
49
                        (aWeekday = #Sunday or: [ aWeekday = #Saturday ]) ifTrue: [
×
NEW
50
                                groupedByDate removeKey: date ] ] ].
×
NEW
51

×
NEW
52

×
NEW
53
        groupedByDate
×
NEW
54
                at: end printString
×
NEW
55
                ifAbsentPut: [ OrderedCollection new ].
×
NEW
56

×
NEW
57
        ^ groupedByDate
×
NEW
58
]
×
59

60
{ #category : #'as yet unclassified' }
NEW
61
GitMetric class >> transformDate: date to: aWeekOrMonthOrYear [
×
NEW
62

×
NEW
63
        aWeekOrMonthOrYear = Month ifTrue: [ ^ date asDate month asDate ].
×
NEW
64

×
NEW
65
        ^ (date asDate perform: ('as' , aWeekOrMonthOrYear name) asSymbol)
×
NEW
66
                  asDate
×
NEW
67
]
×
68

69
{ #category : #'as yet unclassified' }
NEW
70
GitMetric >> cacheSymbolFor: anEntityType since: since until: until [
×
NEW
71

×
NEW
72
        ^ (anEntityType printString , ' since ' , since printString , ' to '
×
NEW
73
           , until printString) asSymbol
×
NEW
74
]
×
75

76
{ #category : #'as yet unclassified' }
NEW
77
GitMetric >> findUserNamed: aUsername [
×
NEW
78

×
NEW
79
        user := glhImporter importUserByUsername: aUsername.
×
NEW
80
        ^ user
×
NEW
81
]
×
82

83
{ #category : #accessing }
NEW
84
GitMetric >> glhImporter: aGLPHModelImporter [ 
×
NEW
85
        glhImporter := aGLPHModelImporter
×
NEW
86
]
×
87

88
{ #category : #churn }
NEW
89
GitMetric >> loadCommitOfProjects: aCollection since: since until: until [
×
NEW
90

×
NEW
91
        | allCommits period size |
×
NEW
92
        period := self cacheSymbolFor: GLHCommit since: since until: until.
×
NEW
93

×
NEW
94
        "download commits unless project cache is not empty"
×
NEW
95
        allCommits := aCollection collect: [ :idProject |
×
NEW
96
                              | project |
×
NEW
97
                              project := itsProjects at: idProject.
×
NEW
98
                              project repository cacheAt: period ifAbsentPut: [
×
NEW
99
                                      | foundCommits |
×
NEW
100
                                      foundCommits := glhImporter
×
NEW
101
                                                              importCommitsOProject: project
×
NEW
102
                                                              since: since
×
NEW
103
                                                              until: until.
×
NEW
104
                                      foundCommits ] ].
×
NEW
105

×
NEW
106
        allCommits := allCommits flatten.
×
NEW
107

×
NEW
108
        size := allCommits size.
×
NEW
109
        allCommits do: [ :commit |
×
NEW
110
                MyLogs logProgress: 'import creators ' over: size.
×
NEW
111
                glhImporter importCreatorOfCommit: commit ].
×
NEW
112

×
NEW
113
        glhImporter chainsCommitsFrom: allCommits.
×
NEW
114

×
NEW
115
        ^ allCommits
×
NEW
116
]
×
117

118
{ #category : #churn }
NEW
119
GitMetric >> loadMergeRequestsOfProjects: aCollection since: since until: until [
×
NEW
120

×
NEW
121
        | allMr period |
×
NEW
122
        "itsMergeRequests ifNil: [ itsMergeRequests := Dictionary new ]."
×
NEW
123
        period := self cacheSymbolFor: GLPHEMergeRequest since: since until: until.
×
NEW
124

×
NEW
125
        allMr := aCollection collect: [ :idProject |
×
NEW
126
                         | project mr |
×
NEW
127
                         project := itsProjects at: idProject.
×
NEW
128
                         project cacheAt: period ifAbsentPut: [
×
NEW
129
                                 mr := glhImporter
×
NEW
130
                                               importMergeRequests: project
×
NEW
131
                                               since: since
×
NEW
132
                                               until: until.
×
NEW
133
                                 mr ] ].
×
NEW
134

×
NEW
135
        ^ allMr flattened
×
NEW
136
]
×
137

138
{ #category : #loading }
NEW
139
GitMetric >> loadProjects: projectIds [
×
NEW
140

×
NEW
141
        projectIds do: [ :id |
×
NEW
142
                
×
NEW
143
                itsProjects at: id ifAbsentPut: [ glhImporter importProject: id ] ].
×
NEW
144

×
NEW
145
        ^ itsProjects
×
NEW
146
]
×
147

148
{ #category : #setup }
NEW
149
GitMetric >> setupGroupedDateFrom: since to: until over: aDateWeekMonthOrYear [
×
NEW
150

×
NEW
151
        | groupedByDate start end over increment |
×
NEW
152
        groupedByDate := OrderedDictionary new.
×
NEW
153

×
NEW
154
        increment := 1.
×
NEW
155
        start := self transformDate: since to: aDateWeekMonthOrYear.
×
NEW
156
        end := self transformDate: until to: aDateWeekMonthOrYear.
×
NEW
157

×
NEW
158
        groupedByDate
×
NEW
159
                at: start printString
×
NEW
160
                ifAbsentPut: [ OrderedCollection new ].
×
NEW
161

×
NEW
162
        over := aDateWeekMonthOrYear name asLowercase asSymbol.
×
NEW
163
        over = #date ifTrue: [ over := #day ].
×
NEW
164
        over = #month ifTrue: [
×
NEW
165
                increment := 32.
×
NEW
166
                over := #day ].
×
NEW
167

×
NEW
168

×
NEW
169
        [ groupedByDate keys last asDateAndTime < end ] whileTrue: [
×
NEW
170
                | index |
×
NEW
171
                index := groupedByDate keys last asDateAndTime
×
NEW
172
                         + (increment perform: over).
×
NEW
173
                index := self transformDate: index to: aDateWeekMonthOrYear.
×
NEW
174
                groupedByDate
×
NEW
175
                        at: index printString
×
NEW
176
                        ifAbsentPut: [ OrderedCollection new ] ].
×
NEW
177

×
NEW
178

×
NEW
179
        over = #day ifTrue: [
×
NEW
180
                groupedByDate keysDo: [ :date |
×
NEW
181
                        | aWeekday |
×
NEW
182
                        aWeekday := date asDate weekday.
×
NEW
183
                        (aWeekday = #Sunday or: [ aWeekday = #Saturday ]) ifTrue: [
×
NEW
184
                                groupedByDate removeKey: date ] ] ].
×
NEW
185

×
NEW
186

×
NEW
187
        groupedByDate
×
NEW
188
                at: end printString
×
NEW
189
                ifAbsentPut: [ OrderedCollection new ].
×
NEW
190

×
NEW
191
        ^ groupedByDate
×
NEW
192
]
×
193

194
{ #category : #'as yet unclassified' }
NEW
195
GitMetric >> transformDate: date to: aWeekOrMonthOrYear [
×
NEW
196

×
NEW
197
        aWeekOrMonthOrYear = Month ifTrue: [ ^ date asDate month asDate ].
×
NEW
198

×
NEW
199
        ^ (date asDate perform: ('as' , aWeekOrMonthOrYear name) asSymbol)
×
NEW
200
                  asDate
×
NEW
201
]
×
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