• 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/GitMetric4User.class.st
1
Class {
2
        #name : #GitMetric4User,
3
        #superclass : #GitMetric,
4
        #instVars : [
5
                'itsCommits',
6
                'itsMergeRequests'
7
        ],
8
        #category : #'GitLabHealth-Model-Analysis'
9
}
10

11
{ #category : #churn }
12
GitMetric4User >> codeChurnSince: since until: until onACommitWindowOf: commitLimit overA: aDateWeekMonthOrYear [
×
13

×
14
        | commits res groupedByDate totalContributions userCommits |
×
15
        "for each commit, we get its churn result (a dictionnary)"
×
16
        'GitMetric4User: code churn' recordInfo.
×
17
        totalContributions := OrderedCollection new.
×
18
        groupedByDate := self
×
19
                                 setupGroupedDateFrom: since
×
20
                                 to: until
×
21
                                 over: aDateWeekMonthOrYear.
×
22
        gitAnalyzer := GitAnalyzer new
×
23
                               glhImporter: glhImporter;
×
24
                               onModel: glhModel;
×
25
                               maxChildCommit: commitLimit.
×
26
        glhImporter withCommitDiffs: false.
×
27
        commits := self
×
NEW
28
                           loadCommitsFromProjectsIds: itsProjects keys
×
29
                           since: since
×
30
                           until: until.
×
31
        glhImporter withCommitDiffs: true.
×
32
        userCommits := commits reject: [ :commit |
×
33
                               commit commitCreator ~= user ].
×
34
        commits := self
×
35
                           foundSuccessorOf: userCommits
×
36
                           andCompleteImportForMax: commitLimit.
×
37

×
38

×
39
        res := commits collect: [ :commit |
×
40
                       commit -> (gitAnalyzer
×
41
                                fromCommit: commit;
×
42
                                analyseChurn) ].
×
43
        res do: [ :commits4Churns |
×
44
                | commit allChurnsInCommit sumChurnInCommit overDate contribution churnOnCommit |
×
45
                commit := commits4Churns key.
×
46
                allChurnsInCommit := commits4Churns value.
×
47
                sumChurnInCommit := (allChurnsInCommit at: #churns) sum: [ :churn |
×
48
                                            | numerator |
×
49
                                            numerator := churn value at: #churnLoC.
×
50
                                            numerator ].
×
51
                contribution := allChurnsInCommit at: #totalContribution.
×
52
                totalContributions add: contribution.
×
53
                churnOnCommit := {
×
54
                                         (#churnOnCommit -> sumChurnInCommit).
×
55
                                         (#LoCOnCommit -> contribution) } asDictionary.
×
56
                overDate := self
×
57
                                    transformDate: commit created_at
×
58
                                    to: aDateWeekMonthOrYear.
×
59
                groupedByDate
×
60
                        at: overDate printString
×
61
                        ifPresent: [ :array | array add: churnOnCommit ]
×
62
                        ifAbsentPut: [
×
63
                                OrderedCollection new
×
64
                                        add: churnOnCommit;
×
65
                                        yourself ] ].
×
66
        groupedByDate := groupedByDate collect: [ :churnsAtDate |
×
67
                                 | totalChurn totalContribution percentage |
×
68
                                 totalChurn := churnsAtDate sum: [ :churn |
×
69
                                                       churn at: #churnOnCommit ].
×
70
                                 totalContribution := churnsAtDate sum: [ :churn |
×
71
                                                              churn at: #LoCOnCommit ].
×
72
                                 totalContribution = 0
×
73
                                         ifTrue: [ percentage := 0 asFloat ]
×
74
                                         ifFalse: [
×
75
                                         percentage := (totalChurn * 100
×
76
                                                        / totalContribution) asFloat ].
×
77
                                 {
×
78
                                         (#churn -> totalChurn).
×
79
                                         (#contribution -> totalContribution).
×
80
                                         (#percentage -> percentage) } asDictionary ].
×
81
        ^ {
×
82
                  (#details -> groupedByDate).
×
83
                  (#totalContribution -> (totalContributions
×
84
                            ifEmpty: [ 0 ]
×
85
                            ifNotEmpty: [ totalContributions sum ])).
×
86
                  (#totalChurn -> (groupedByDate sum: [ :date | date at: #churn ])).
×
87
                  (#churn
×
88
                   ->
×
89
                   (groupedByDate collect: [ :date | date at: #percentage ]) average).
×
90
                  (#overEach -> aDateWeekMonthOrYear name).
×
91
                  (#forOver -> (groupedByDate keys size printString
×
92
                    , aDateWeekMonthOrYear printString)).
×
93
                  (#userCommits -> commits size).
×
94
                  (#churnWindow -> commitLimit) } asDictionary
×
95
]
×
96

97
{ #category : #metrics }
98
GitMetric4User >> codeContributionsSince: since until: until overA: aDateWeekMonthOrYear [
×
99

×
100
        | commits contributions groupedByDate |
×
101
        'GitMetric4User: code contribution' recordInfo.
×
NEW
102

×
103
        groupedByDate := self
×
104
                                 setupGroupedDateFrom: since
×
105
                                 to: until
×
106
                                 over: aDateWeekMonthOrYear.
×
107

×
108
        gitAnalyzer := GitAnalyzer new
×
109
                               onModel: glhModel;
×
110
                               glhImporter: glhImporter.
×
111

×
112
        glhImporter withCommitDiffs: false.
×
113
        commits := self
×
NEW
114
                           loadCommitsFromProjectsIds: itsProjects keys
×
115
                           since: since
×
116
                           until: until.
×
117
        glhImporter withCommitDiffs: true.
×
118
        commits := commits reject: [ :commit | commit commitCreator ~= user ].
×
119

×
120
        contributions := commits collect: [ :commit |
×
121
                                 commit -> (gitAnalyzer
×
122
                                          fromCommit: commit;
×
123
                                          analyseCommitContribution) ].
×
124

×
125
        contributions do: [ :assoc |
×
126
                | dateOver |
×
127
                dateOver := self
×
128
                                    transformDate: assoc key created_at
×
129
                                    to: aDateWeekMonthOrYear.
×
130
                groupedByDate
×
131
                        at: dateOver printString
×
132
                        ifPresent: [ :v | v add: assoc value ]
×
133
                        ifAbsentPut: [
×
134
                                OrderedCollection new
×
135
                                        add: assoc value;
×
136
                                        yourself ] ].
×
137

×
138
        groupedByDate := groupedByDate collect: [ :contribs |
×
139
                                 | totalAdd totalDele |
×
140
                                 totalAdd := contribs sum: [ :v | v at: #addition ].
×
141
                                 totalDele := contribs sum: [ :v | v at: #deletion ].
×
142
                                 {
×
143
                                         (#addition -> totalAdd).
×
144
                                         (#deletion -> totalDele) } asDictionary ].
×
145

×
146
        ^ {
×
147
                  (#overEach -> aDateWeekMonthOrYear name).
×
148
                  (#forOver -> (groupedByDate keys size printString
×
149
                    , aDateWeekMonthOrYear printString)).
×
150
                  (#avgAddition
×
151
                   ->
×
152
                   (groupedByDate collect: [ :d | d at: #addition ]) average asFloat).
×
153
                  (#avgDeletion
×
154
                   ->
×
155
                   (groupedByDate collect: [ :d | d at: #deletion ]) average asFloat).
×
156
                  (#details -> groupedByDate).
×
157
                  (#userCommits -> commits size) } asDictionary
×
158
]
×
159

160
{ #category : #metrics }
161
GitMetric4User >> commentsContributionsSince: since until: until overA: aDateWeekMonthOrYear [
×
162

×
163
        | commits contributions groupedByDate |
×
164
        'GitMetric4User: comment contribution' recordInfo.
×
165

×
166
        groupedByDate := self
×
167
                                 setupGroupedDateFrom: since
×
168
                                 to: until
×
169
                                 over: aDateWeekMonthOrYear.
×
170

×
171
        gitAnalyzer := GitAnalyzer new
×
172
                               onModel: glhModel;
×
173
                               glhImporter: glhImporter.
×
174

×
175
        glhImporter withCommitDiffs: false.
×
176
        commits := self
×
NEW
177
                           loadCommitsFromProjectsIds: itsProjects keys
×
178
                           since: since
×
179
                           until: until.
×
180
        glhImporter withCommitDiffs: true.
×
181
        commits := commits reject: [ :commit | commit commitCreator ~= user ].
×
182
        commits do: [ :commit | glhImporter completeImportedCommit: commit ].
×
183

×
184

×
185
        contributions := commits collect: [ :commit |
×
186
                                 commit -> (gitAnalyzer
×
187
                                          fromCommit: commit;
×
188
                                          analyseCommentContribution) ].
×
189

×
190

×
191
        contributions do: [ :assoc |
×
192
                | dateOver |
×
193
                dateOver := self
×
194
                                    transformDate: assoc key created_at
×
195
                                    to: aDateWeekMonthOrYear.
×
196
                groupedByDate
×
197
                        at: dateOver printString
×
198
                        ifPresent: [ :v | v add: assoc value ]
×
199
                        ifAbsentPut: [
×
200
                                OrderedCollection new
×
201
                                        add: assoc value;
×
202
                                        yourself ] ].
×
203

×
204
        groupedByDate := groupedByDate collect: [ :contribs |
×
205
                                 contribs
×
206
                                         ifNotEmpty: [ contribs sum ]
×
207
                                         ifEmpty: [ 0 ] ].
×
208

×
209

×
210
        ^ {
×
211
                  (#details -> groupedByDate).
×
212
                  (#totalComments -> groupedByDate values sum).
×
213
                  (#avgComments -> groupedByDate values average asFloat).
×
214
                  (#overEach -> aDateWeekMonthOrYear name).
×
215
                  (#forOver -> (groupedByDate keys size printString
×
216
                    , aDateWeekMonthOrYear printString)).
×
217
                  (#userCommits -> commits size) } asDictionary
×
218
]
×
219

220
{ #category : #metrics }
221
GitMetric4User >> commitFrequencySince: since until: until overA: aDateWeekMonthOrYear [
×
222

×
223
        | periods total groupedByDate userCommits |
×
224
        'GitMetric4User: commit frequency' recordInfo.
×
225

×
226
        groupedByDate := self
×
227
                                 setupGroupedDateFrom: since
×
228
                                 to: until
×
229
                                 over: aDateWeekMonthOrYear.
×
230

×
231
        glhImporter withCommitDiffs: false.
×
232
        userCommits := self
×
NEW
233
                               loadCommitsFromProjectsIds: itsProjects keys
×
234
                               since: since
×
235
                               until: until.
×
236
        glhImporter withCommitDiffs: true.
×
237
        userCommits := userCommits reject: [ :c | c commitCreator ~= user ].
×
238

×
239
        userCommits do: [ :c |
×
240
                | dateOver |
×
241
                dateOver := self
×
242
                                    transformDate: c created_at
×
243
                                    to: aDateWeekMonthOrYear.
×
244
                groupedByDate at: dateOver printString ifPresent: [ :v | v add: c ] ].
×
245

×
246
        periods := groupedByDate keys size.
×
247
        total := groupedByDate values sum: [ :commits | commits size ].
×
248

×
249

×
250
        ^ {
×
251
                  (#averageFrac -> (total / periods)).
×
252
                  (#averageFloat -> (total / periods) asFloat).
×
253
                  (#userCommit -> total).
×
254
                  (#forOver -> (groupedByDate keys size printString
×
255
                    , aDateWeekMonthOrYear printString)).
×
256
                  (#periode -> aDateWeekMonthOrYear name).
×
257
                  (#details -> groupedByDate) } asOrderedDictionary
×
258
]
×
259

260
{ #category : #'as yet unclassified' }
261
GitMetric4User >> commitsProducedOnProject: projectId since: sinceDate until: untilDate [
×
262

×
263
        | frequencies |
×
264
        
×
265
        
×
266
        gitAnalyzer := GitAnalyzer new 
×
267
        glhImporter: glhImporter; 
×
268
        onModel: glhModel.
×
269
         
×
270
        frequencies := gitAnalyzer
×
271
                               onProject: (itsProjects at: projectId);
×
272
                               analyseCommitFrequencySince: sinceDate
×
273
                               until: untilDate. 
×
274
        
×
275
        "complete each commit "
×
276
        frequencies values flattened do: [ :commit |
×
277
                glhImporter completeImportedCommit: commit.
×
278
                 ].
×
279
        
×
280
        "Filter the associations in the 'frequencies' collection, removing any commits not created by the specified 'user'. "
×
281
        frequencies associations do: [ :assoc |
×
282
                |commits| 
×
283
                commits := assoc value.
×
284
                assoc value: (commits reject: [ :commit | commit commitCreator ~= user ]). 
×
285
        ].
×
286
        
×
287
        ^ frequencies 
×
288
]
×
289

290
{ #category : #metrics }
291
GitMetric4User >> commitsProducedOnProject: aProjectId since: since until: until overA: aWeekOrMonthOrYear [
×
292
        "'aWeekOrMonthOrYear' should be the class of Data, Week, Month or Year"
×
293

×
294
        | frequency aggregatedFrequencies |
×
295
        aggregatedFrequencies := self
×
296
                                         setupGroupedDateFrom: since
×
297
                                         to: until
×
298
                                         over: aWeekOrMonthOrYear.
×
299

×
300
        frequency := self
×
301
                             commitsProducedOnProject: aProjectId
×
302
                             since: since
×
303
                             until: until.
×
304

×
305
        frequency associations do: [ :assoc |
×
306
                | date commits overDate |
×
307
                date := assoc key.
×
308
                commits := assoc value.
×
309

×
310
                commits ifNotEmpty: [ " convert the date as its week date. For some english reason, the week start in sunday so we should add a + 1 day "
×
311
                        overDate := self transformDate: date to: aWeekOrMonthOrYear.
×
312
                        aggregatedFrequencies
×
313
                                at: overDate printString
×
314
                                ifPresent: [ :collection | collection addAll: commits ]
×
315
                                ifAbsentPut: [ commits ] ] ].
×
316

×
317
        ^ aggregatedFrequencies
×
318
]
×
319

320
{ #category : #churn }
321
GitMetric4User >> delayUntilFirstChurnSince: since until: until onACommitWindowOf: maxCommitWindow overA: aDateWeekMonthOrYear [
×
322

×
323
        | commits groupedByDate res avg userCommits |
×
324
        'GitMetric4User: delay until first churn' recordInfo.
×
325

×
326
        groupedByDate := self
×
327
                                 setupGroupedDateFrom: since
×
328
                                 to: until
×
329
                                 over: aDateWeekMonthOrYear.
×
330

×
331
        glhImporter withCommitDiffs: false.
×
332
        commits := self
×
NEW
333
                           loadCommitsFromProjectsIds: itsProjects keys
×
334
                           since: since
×
335
                           until: until.
×
336
        glhImporter withCommitDiffs: true.
×
337

×
338
        userCommits := commits reject: [ :commit |
×
339
                               commit commitCreator ~= user ].
×
340
        commits := self
×
341
                           foundSuccessorOf: userCommits
×
342
                           andCompleteImportForMax: maxCommitWindow.
×
343

×
344

×
345
        "class commit by dates, filter none user commits"
×
346
        commits do: [ :commit |
×
347
                commit commitCreator = user ifTrue: [
×
348
                        | overDate |
×
349
                        overDate := self
×
350
                                            transformDate: commit created_at
×
351
                                            to: aDateWeekMonthOrYear.
×
352

×
353
                        groupedByDate
×
354
                                at: overDate printString
×
355
                                ifPresent: [ :arrayOfCommits | arrayOfCommits add: commit ]
×
356
                                ifAbsentPut: [
×
357
                                        OrderedCollection new
×
358
                                                add: commit;
×
359
                                                yourself ] ] ].
×
360

×
361

×
362

×
363
        res := groupedByDate collect: [ :commits4Date |
×
364
                       | durationFromA2B |
×
365
                       commits4Date collect: [ :commitA |
×
366
                               | commitB |
×
367
                               commitB := GitAnalyzer new
×
368
                                                  glhImporter: glhImporter;
×
369
                                                  onModel: glhModel;
×
370
                                                  fromCommit: commitA;
×
371
                                                  maxChildCommit: maxCommitWindow;
×
372
                                                  analyseDelayUntilFirstChurn.
×
373

×
374
                               durationFromA2B := commitB
×
375
                                                          ifNil: [ 0 ]
×
376
                                                          ifNotNil: [
×
377
                                                          commitB created_at - commitA created_at ].
×
378
                               durationFromA2B ] ].
×
379

×
380

×
381

×
382
        res := res collect: [ :durationsByDate |
×
383
                       | filtered |
×
384
                       filtered := durationsByDate reject: [ :value | value = 0 ].
×
385
                       filtered isEmpty
×
386
                               ifTrue: [ nil ]
×
387
                               ifFalse: [
×
388
                               (filtered sum: [ :v | v asDuration asSeconds]) / filtered size ] ].
×
389

×
390
        res := res reject: #isNil.
×
391

×
392
        res
×
393
                ifEmpty: [ avg := nil ]
×
394
                ifNotEmpty: [ avg := res values average asFloat ].
×
395

×
396

×
397
        ^ {
×
398
                  (#avgDelay -> avg).
×
399
                  (#overEach -> aDateWeekMonthOrYear name).
×
400
                  (#forOver -> (groupedByDate keys size printString
×
401
                    , aDateWeekMonthOrYear printString)).
×
402
                  (#details -> groupedByDate) } asDictionary
×
403
]
×
404

405
{ #category : #churn }
406
GitMetric4User >> delayUntilFirstChurnSince: since until: until overA: aDateWeekMonthOrYear [
×
407

×
408
        | commits groupedByDate res avg |
×
409
        self
×
410
                deprecated:
×
411
                'Use #delayUntilFirstChurnSince:until:onACommitWindowOf:overA: instead'
×
412
                on: '1 July 2024'
×
413
                in:
×
414
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
×
415

×
416
        'GitMetric4User: delay until first churn' recordInfo.
×
417

×
418
        groupedByDate := self
×
419
                                 setupGroupedDateFrom: since
×
420
                                 to: until
×
421
                                 over: aDateWeekMonthOrYear.
×
422

×
423
        commits := self
×
NEW
424
                           loadCommitsFromProjectsIds: itsProjects keys
×
425
                           since: since
×
426
                           until: until.
×
427

×
428
        "class commit by dates, filter none user commits"
×
429
        commits do: [ :commit |
×
430
                commit commitCreator = user ifTrue: [
×
431
                        | overDate |
×
432
                        overDate := self
×
433
                                            transformDate: commit created_at
×
434
                                            to: aDateWeekMonthOrYear.
×
435

×
436
                        groupedByDate
×
437
                                at: overDate printString
×
438
                                ifPresent: [ :arrayOfCommits | arrayOfCommits add: commit ]
×
439
                                ifAbsentPut: [
×
440
                                        OrderedCollection new
×
441
                                                add: commit;
×
442
                                                yourself ] ] ].
×
443

×
444

×
445

×
446
        res := groupedByDate collect: [ :commits4Date |
×
447
                       | durationFromA2B |
×
448
                       commits4Date collect: [ :commitA |
×
449
                               | commitB |
×
450
                               commitB := GitAnalyzer new
×
451
                                                  glhImporter: glhImporter;
×
452
                                                  onModel: glhModel;
×
453
                                                  fromCommit: commitA;
×
454
                                                  maxChildCommit: 5;
×
455
                                                  analyseDelayUntilFirstChurn.
×
456

×
457
                               durationFromA2B := commitB
×
458
                                                          ifNil: [ 0 ]
×
459
                                                          ifNotNil: [
×
460
                                                          commitB created_at - commitA created_at ].
×
461
                               durationFromA2B ] ].
×
462

×
463

×
464

×
465
        res := res collect: [ :durationsByDate |
×
466
                       | filtered |
×
467
                       filtered := durationsByDate reject: [ :value | value = 0 ].
×
468
                       filtered isEmpty
×
469
                               ifTrue: [ nil ]
×
470
                               ifFalse: [
×
471
                               (filtered sum: [ :v | v asDuration ]) / filtered size ] ].
×
472

×
473
        res := res reject: #isNil.
×
474

×
475
        res
×
476
                ifEmpty: [ avg := nil ]
×
477
                ifNotEmpty: [ avg := res values sum / res keys size ].
×
478

×
479

×
480
        ^ {
×
481
                  (#avgDelay -> avg).
×
482
                  (#overEach -> aDateWeekMonthOrYear name).
×
483
                  (#forOver -> (groupedByDate keys size printString
×
484
                    , aDateWeekMonthOrYear printString)).
×
485
                  (#details -> groupedByDate) } asDictionary
×
486
]
×
487

488
{ #category : #churn }
489
GitMetric4User >> foundSuccessorOf: userCommits andCompleteImportForMax: commitLimit [
×
490

×
NEW
491
        | analyzingCommits i size|
×
492
        analyzingCommits := Set new.
×
493
        glhImporter withCommitDiffs: true.
×
494

×
495
        userCommits do: [ :c |
×
496
                gitAnalyzer
×
497
                        visitChildCommits: c childCommits
×
498
                        toStoreThemIn: analyzingCommits
×
499
                        upto: commitLimit ].
×
500

×
NEW
501
        i := 0.
×
NEW
502
        size := analyzingCommits size. 
×
503
        analyzingCommits do: [ :c |
×
NEW
504
                ('import complete commits  [' , (i:=i+1) printString, '/', size printString , ']'  ) recordInfo.
×
505
                glhImporter completeImportedCommit: c ].
×
NEW
506

×
507
        ^ analyzingCommits
×
508
]
×
509

510
{ #category : #initialization }
511
GitMetric4User >> initialize [
×
512

×
513
        user := GLHUser new.
×
514
        itsProjects := Dictionary new.
×
515
        itsCommits := Dictionary new.
×
516
        itsMergeRequests := Dictionary new
×
517
]
×
518

519
{ #category : #accessing }
520
GitMetric4User >> itsProjects: projects [
×
521
        itsProjects := projects .
×
522
]
×
523

524
{ #category : #churn }
525
GitMetric4User >> loadCommitOfProjects: aCollection since: aTimespan [
×
526
        |commits|
×
527
        
×
528
        commits := (aCollection collect: [ :id |
×
529
                 glhImporter
×
530
                        importCommitsOProject: (itsProjects at: id)
×
531
                        since: aTimespan
×
532
                        until: nil ]) flattened.
×
533

×
534
        commits do: [ :commit |
×
535
                glhImporter completeImportedCommit: commit. 
×
536
                 ].
×
537

×
538
        ^ self userCommits.
×
539
]
×
540

541
{ #category : #metrics }
542
GitMetric4User >> mergeRequestDurationSince: since until: until overA: aDateWeekMonthOrYear [
×
543

×
544
        | mergeRequest res groupedByDate filterGroups avg |
×
545
        groupedByDate := self
×
546
                                 setupGroupedDateFrom: since
×
547
                                 to: until
×
548
                                 over: aDateWeekMonthOrYear.
×
549

×
550
        gitAnalyzer := GitAnalyzer new
×
551
                               glhImporter: glhImporter;
×
552
                               onModel: glhModel.
×
553

×
554
        glhImporter withCommitDiffs: false.
×
555
        mergeRequest := self
×
NEW
556
                                loadMergeRequestsFromProjectsIds: itsProjects keys
×
557
                                since: since
×
558
                                until: until.
×
559
        glhImporter withCommitDiffs: true.
×
560

×
561
        mergeRequest ifEmpty: [
×
562
                ^ {
×
563
                          (#avgDuration -> nil).
×
564
                          (#overEach -> aDateWeekMonthOrYear name).
×
565
                          (#forOver -> (groupedByDate keys size printString
×
566
                            , aDateWeekMonthOrYear printString)).
×
567
                          (#totalMergeRequest -> 0).
×
568
                          (#details -> nil) } asDictionary ].
×
569

×
570
        res := mergeRequest collect: [ :mr |
×
571
                       gitAnalyzer analyseMergeResquestValidation: mr ].
×
572

×
573

×
574
        res do: [ :dic |
×
575
                | overDate |
×
576
                overDate := self
×
577
                                    transformDate: (dic at: #created_at)
×
578
                                    to: aDateWeekMonthOrYear.
×
579

×
580
                groupedByDate
×
581
                        at: overDate printString
×
582
                        ifPresent: [ :durations | durations add: (dic at: #duration) ]
×
583
                        ifAbsentPut: [
×
584
                                OrderedCollection new
×
585
                                        add: (dic at: #duration);
×
586
                                        yourself ] ].
×
587

×
588

×
589
        filterGroups := groupedByDate reject: [ :array | array isEmpty ].
×
590

×
591
        filterGroups associations do: [ :assoc |
×
592
                | sum denominator |
×
593
                denominator := assoc value size.
×
594

×
595
                sum := assoc value sum: [ :v |
×
596
                               v ifNil: [
×
597
                                       denominator := denominator - 1.
×
598
                                       0 asDuration ] ].
×
599
                denominator = 0 ifTrue: [ denominator := 1 ].
×
600

×
601
                filterGroups at: assoc key put: sum / denominator ].
×
602

×
603

×
604
        filterGroups keys
×
605
                ifEmpty: [ avg := 0 ]
×
606
                ifNotEmpty: [
×
607
                avg := filterGroups values sum / filterGroups keys size ].
×
608

×
609

×
610
        ^ {
×
611
                  (#avgDuration -> avg).
×
612
                  (#overEach -> aDateWeekMonthOrYear name).
×
613
                  (#forOver -> (groupedByDate keys size printString
×
614
                    , aDateWeekMonthOrYear printString)).
×
615
                  (#totalMergeRequest -> mergeRequest size).
×
616
                  (#details -> groupedByDate) } asDictionary
×
617
]
×
618

619
{ #category : #accessing }
620
GitMetric4User >> user [
×
621
        ^ user
×
622
]
×
623

624
{ #category : #accessing }
625
GitMetric4User >> user: anUser [
×
626
        user := anUser. 
×
627
]
×
628

629
{ #category : #accessing }
630
GitMetric4User >> userCommits [
×
631
        ^ user commits
×
632
]
×
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