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

moosetechnology / GitProjectHealth / 10181630875

31 Jul 2024 01:54PM UTC coverage: 33.667% (+0.2%) from 33.456%
10181630875

push

github

HLAD Nicolas
Merge 120ab31b6

37 of 123 new or added lines in 6 files covered. (30.08%)

2 existing lines in 1 file now uncovered.

2726 of 8097 relevant lines covered (33.67%)

0.34 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 }
15
GitMetric class >> setupGroupedDateFrom: since to: until over: aDateWeekMonthOrYear [
×
16

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

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

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

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

×
34

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

×
44

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

×
52

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

×
57
        ^ groupedByDate
×
58
]
×
59

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

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

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

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

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

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

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

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

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

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

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

×
106
        allCommits := allCommits flatten.
×
107

×
NEW
108
        i := 0. 
×
109
        size := allCommits size.
×
110
        allCommits do: [ :commit |
×
NEW
111
                ('import commit creators [',  (i:=i+1) printString,  '/', size printString) recordInfo. 
×
NEW
112

×
113
                glhImporter importCreatorOfCommit: commit ].
×
114

×
115
        glhImporter chainsCommitsFrom: allCommits.
×
116

×
117
        ^ allCommits
×
118
]
×
119

120
{ #category : #churn }
NEW
121
GitMetric >> loadMergeRequestsFromProjectsIds: aCollection since: since until: until [
×
122

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

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

×
137
        ^ allMr flattened
×
138
]
×
139

140
{ #category : #loading }
NEW
141
GitMetric >> loadProjectsFromIds: projectIds [
×
142

×
143
        projectIds do: [ :id |
×
144
                
×
145
                itsProjects at: id ifAbsentPut: [ glhImporter importProject: id ] ].
×
146

×
147
        ^ itsProjects
×
148
]
×
149

150
{ #category : #setup }
151
GitMetric >> setupGroupedDateFrom: since to: until over: aDateWeekMonthOrYear [
×
152

×
153
        | groupedByDate start end over increment |
×
154
        groupedByDate := OrderedDictionary new.
×
155

×
156
        increment := 1.
×
157
        start := self transformDate: since to: aDateWeekMonthOrYear.
×
158
        end := self transformDate: until to: aDateWeekMonthOrYear.
×
159

×
160
        groupedByDate
×
161
                at: start printString
×
162
                ifAbsentPut: [ OrderedCollection new ].
×
163

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

×
170

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

×
180

×
181
        over = #day ifTrue: [
×
NEW
182
                
×
NEW
183
         groupedByDate :=         (groupedByDate associations select: [ :date |
×
184
                        | aWeekday |
×
NEW
185
                        aWeekday := date key asDate weekday.
×
NEW
186
                        (aWeekday = #Sunday or: [ aWeekday = #Saturday ]) not ]) asOrderedDictionary ].
×
187

×
188

×
189
        groupedByDate
×
190
                at: end printString
×
191
                ifAbsentPut: [ OrderedCollection new ].
×
192

×
193
        ^ groupedByDate
×
194
]
×
195

196
{ #category : #'as yet unclassified' }
197
GitMetric >> transformDate: date to: aWeekOrMonthOrYear [
×
198

×
199
        aWeekOrMonthOrYear = Month ifTrue: [ ^ date asDate month asDate ].
×
200

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