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

moosetechnology / GitProjectHealth / 9549969001

17 Jun 2024 02:58PM UTC coverage: 26.896% (-2.6%) from 29.45%
9549969001

push

github

HLAD Nicolas
Merge 10a1182e1

1830 of 6804 relevant lines covered (26.9%)

0.27 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 : #Object,
4
        #instVars : [
5
                'user',
6
                'itsProjects',
7
                'itsGroups',
8
                'itsCommits',
9
                'gitAnalyzer',
10
                'glhModel',
11
                'glhImporter',
12
                'itsMergeRequests'
13
        ],
14
        #category : #'GitLabHealth-Model-Analysis'
15
}
16

17
{ #category : #churn }
18
GitMetric4User >> codeChurnSince: since until: until onACommitWindowOf: commitLimit overA: aDateWeekMonthOrYear [
×
19

×
20
        | commits res groupedByDate totalContributions |
×
21
        
×
22
                ('GitMetric4User: code churn')
×
23
                recordInfo.
×
24
        
×
25
        totalContributions := OrderedCollection new.
×
26
                groupedByDate := self
×
27
                                 setupGroupedDateFrom: since
×
28
                                 to: until
×
29
                                 over: aDateWeekMonthOrYear.
×
30
        gitAnalyzer := GitAnalyzer new
×
31
                               glhImporter: glhImporter;
×
32
                               onModel: glhModel;
×
33
                               maxChildCommit: commitLimit.
×
34

×
35
        commits := self
×
36
                           loadCommitOfProjects: itsProjects keys
×
37
                           since: since
×
38
                           until: until.
×
39
        commits := commits reject: [ :commit | commit commitCreator ~= user ].
×
40

×
41

×
42
        "for each commit, we get its churn result (a dictionnary)"
×
43
        res := commits collect: [ :commit |
×
44
                       commit -> (gitAnalyzer
×
45
                                fromCommit: commit;
×
46
                                analyseChurn) ].
×
47

×
48

×
49
        res do: [ :assoc |
×
50
                | commit churnResult sumChurn overDate contribution fraction |
×
51
                commit := assoc key.
×
52
                churnResult := assoc value.
×
53
                sumChurn := (churnResult at: #churns) sum: [ :churn |
×
54
                                    | numerator |
×
55
                                    numerator := churn value asFraction numerator.
×
56
                                    self flag:
×
57
                                            'must investigate what does it mean to have a -1 in churn'.
×
58
                                    numerator = -1
×
59
                                            ifTrue: [ 0 ]
×
60
                                            ifFalse: [ numerator ] ].
×
61
                contribution := churnResult at: #totalContribution.
×
62
                totalContributions add: contribution.
×
63

×
64
                fraction := sumChurn / ((contribution = 0) ifTrue: [1] ifFalse: [contribution ]) .
×
65
                overDate := self
×
66
                                    transformDate: commit created_at
×
67
                                    to: aDateWeekMonthOrYear.
×
68
                groupedByDate
×
69
                        at: overDate printString
×
70
                        ifPresent: [ :array | array add: fraction ]
×
71
                        ifAbsentPut: [
×
72
                                OrderedCollection new
×
73
                                        add: fraction;
×
74
                                        yourself ] ].
×
75

×
76
        groupedByDate := groupedByDate collect: [ :churns |
×
77
                                 | totalChurn totalContribution |
×
78
                                 totalChurn := churns sum: [ :churn |
×
79
                                                       churn asFraction numerator ].
×
80
                                 totalContribution := churns sum: [ :churn |
×
81
                                                              churn asFraction denominator ].
×
82
                                                         totalContribution = 0 ifTrue: [ totalChurn / 1] ifFalse: [ totalChurn / totalContribution  ]
×
83
                                  ].
×
84

×
85

×
86

×
87
        ^ {
×
88
                  (#details -> groupedByDate).
×
89
                  (#totalContribution -> (totalContributions ifEmpty: [ 0 ] ifNotEmpty: [ totalContributions sum ]) ).
×
90
                  (#totalChurn -> (groupedByDate sum: [ :frac | frac numerator ])).
×
91
                  "(#avgChurn -> ((groupedByDate sum: [ :frac | frac numerator ])
×
92
                    / (groupedByDate keys ifEmpty: [ 1 ] ifNotEmpty: [ groupedByDate keys size ]) ))."
×
93
                  (#churn -> ((groupedByDate sum: [ :frac | frac numerator ]) ->
×
94
                     (groupedByDate sum: [ :frac | frac denominator ]))).
×
95
                  (#overEach -> aDateWeekMonthOrYear name).
×
96
                  (#forOver -> (groupedByDate keys size printString
×
97
                    , aDateWeekMonthOrYear printString)).
×
98
                  (#userCommits -> commits size).
×
99
                  (#churnWindow -> commitLimit) } asDictionary
×
100
]
×
101

102
{ #category : #metrics }
103
GitMetric4User >> codeContributionsSince: since until: until overA: aDateWeekMonthOrYear [
×
104

×
105
        | commits contributions groupedByDate |
×
106
        
×
107
                        ('GitMetric4User: code contribution') recordInfo.
×
108
        
×
109
                glhImporter withCommitDiffs: false.
×
110
        
×
111
                groupedByDate := self
×
112
                                 setupGroupedDateFrom: since
×
113
                                 to: until
×
114
                                 over: aDateWeekMonthOrYear.
×
115
                
×
116
        gitAnalyzer := GitAnalyzer new
×
117
                               onModel: glhModel;
×
118
                               glhImporter: glhImporter.
×
119

×
120
        commits := self
×
121
                           loadCommitOfProjects: itsProjects keys
×
122
                           since: since
×
123
                           until: until.
×
124
        commits := commits reject: [ :commit | commit commitCreator ~= user ].
×
125

×
126
        contributions := commits collect: [ :commit |
×
127
                                 commit -> (gitAnalyzer
×
128
                                          fromCommit: commit;
×
129
                                          analyseCommitContribution) ].
×
130

×
131
        contributions do: [ :assoc |
×
132
                | dateOver |
×
133
                dateOver := self
×
134
                                    transformDate: assoc key created_at
×
135
                                    to: aDateWeekMonthOrYear.
×
136
                groupedByDate
×
137
                        at: dateOver printString
×
138
                        ifPresent: [ :v | v add: assoc value ]
×
139
                        ifAbsentPut: [
×
140
                                OrderedCollection new
×
141
                                        add: assoc value;
×
142
                                        yourself ] ].
×
143

×
144
        groupedByDate := groupedByDate collect: [ :contribs |
×
145
                                 | totalAdd totalDele |
×
146
                                 totalAdd := contribs sum: [ :v | v at: #addition ].
×
147
                                 totalDele := contribs sum: [ :v | v at: #deletion ].
×
148
                                 {
×
149
                                         (#addition -> totalAdd).
×
150
                                         (#deletion -> totalDele) } asDictionary ].
×
151

×
152
                glhImporter withCommitDiffs: true.
×
153

×
154
        ^ {
×
155
                  (#overEach -> aDateWeekMonthOrYear name).
×
156
                  (#forOver -> (groupedByDate keys size printString
×
157
                    , aDateWeekMonthOrYear printString)).
×
158
                  (#avgAddition
×
159
                   -> ((groupedByDate values sum: [ :v | v at: #addition ])
×
160
                            / groupedByDate keys size) asFloat).
×
161
                  (#avgDeletion
×
162
                   -> ((groupedByDate values sum: [ :v | v at: #deletion ])
×
163
                            / groupedByDate keys size) asFloat).
×
164
                  (#details -> groupedByDate).
×
165
                  (#userCommits -> commits size) } asDictionary
×
166
]
×
167

168
{ #category : #metrics }
169
GitMetric4User >> commentsContributionsSince: since until: until overA: aDateWeekMonthOrYear [
×
170

×
171
        | commits contributions groupedByDate |
×
172
        
×
173
                                ('GitMetric4User: comment contribution') recordInfo.
×
174
        
×
175
        groupedByDate := self
×
176
                                 setupGroupedDateFrom: since
×
177
                                 to: until
×
178
                                 over: aDateWeekMonthOrYear.
×
179

×
180
        gitAnalyzer := GitAnalyzer new
×
181
                               onModel: glhModel;
×
182
                               glhImporter: glhImporter.
×
183

×
184
        commits := self
×
185
                           loadCommitOfProjects: itsProjects keys
×
186
                           since: since
×
187
                           until: until.
×
188
        commits := commits reject: [ :commit | commit commitCreator ~= user ].
×
189

×
190
        contributions := commits collect: [ :commit |
×
191
                                 commit -> (gitAnalyzer
×
192
                                          fromCommit: commit;
×
193
                                          analyseCommentContributions) ].
×
194

×
195

×
196
        contributions do: [ :assoc |
×
197
                | dateOver |
×
198
                dateOver := self
×
199
                                    transformDate: assoc key created_at
×
200
                                    to: aDateWeekMonthOrYear.
×
201
                groupedByDate
×
202
                        at: dateOver printString
×
203
                        ifPresent: [ :v | v add: assoc value ]
×
204
                        ifAbsentPut: [
×
205
                                OrderedCollection new
×
206
                                        add: assoc value;
×
207
                                        yourself ] ].
×
208

×
209
        groupedByDate := groupedByDate collect: [ :contribs |
×
210
                                 contribs
×
211
                                         ifNotEmpty: [ contribs sum ]
×
212
                                         ifEmpty: [ 0 ] ].
×
213

×
214

×
215
        ^ {
×
216
                  (#details -> groupedByDate).
×
217
                  (#totalComments -> groupedByDate values sum).
×
218
                  (#avgComments
×
219
                   -> (groupedByDate values sum / groupedByDate keys size)).
×
220
                  (#overEach -> aDateWeekMonthOrYear name).
×
221
                  (#forOver -> (groupedByDate keys size printString
×
222
                    , aDateWeekMonthOrYear printString)).
×
223
                  (#userCommits -> commits size) } asDictionary
×
224
]
×
225

226
{ #category : #metrics }
227
GitMetric4User >> commitFrequencySince: since until: until overA: aDateWeekMonthOrYear [
×
228

×
229
        | all aggregate periods total groupedByDate userCommits |
×
230
        'GitMetric4User: commit frequency' recordInfo.
×
231

×
232
        groupedByDate := self
×
233
                                 setupGroupedDateFrom: since
×
234
                                 to: until
×
235
                                 over: aDateWeekMonthOrYear.
×
236

×
237

×
238
        userCommits := self
×
239
                               loadCommitOfProjects: itsProjects keys
×
240
                               since: since
×
241
                               until: until.
×
242
        userCommits := userCommits reject: [ :c | c commitCreator ~= user ].
×
243

×
244
        userCommits do: [ :c |
×
245
                | dateOver |
×
246
                dateOver := self
×
247
                                    transformDate: c created_at
×
248
                                    to: aDateWeekMonthOrYear.
×
249
                groupedByDate at: dateOver printString ifPresent: [ :v | v add: c ] ].
×
250

×
251

×
252
        periods := groupedByDate keys size.
×
253
        total := groupedByDate values sum: [ :commits | commits size ].
×
254

×
255

×
256
        "aggregate := OrderedDictionary new.
×
257

×
258
        all := itsProjects keys collect: [ :id |
×
259
                       self
×
260
                               commitsProducedOnProject: id
×
261
                               since: since
×
262
                               until: until
×
263
                               overA: aDateWeekMonthOrYear ].
×
264

×
265

×
266
        all do: [ :frequencies |
×
267
                frequencies associations do: [ :assoc |
×
268
                        aggregate
×
269
                                at: assoc key
×
270
                                ifPresent: [ :collection | collection addAll: assoc value ]
×
271
                                ifAbsentPut: [ assoc value ] ] ].
×
272

×
273
        periods := aggregate keys size.
×
274
        total := aggregate values sum: [ :commits | commits size ].
×
275
"
×
276

×
277
        ^ {
×
278
                  (#averageFrac -> (total / periods)).
×
279
                  (#averageFloat -> (total / periods) asFloat).
×
280
                  (#userCommit -> total).
×
281
                  (#forOver -> (groupedByDate keys size printString
×
282
                    , aDateWeekMonthOrYear printString)).
×
283
                  (#periode -> aDateWeekMonthOrYear name).
×
284
                  (#details -> groupedByDate) } asOrderedDictionary
×
285
]
×
286

×
287
{ #category : #'as yet unclassified' }
×
288
GitMetric4User >> commitsProducedOnProject: projectId since: sinceDate until: untilDate [
×
289

×
290
        | frequencies |
×
291
        
×
292
        
×
293
        gitAnalyzer := GitAnalyzer new 
×
294
        glhImporter: glhImporter; 
×
295
        onModel: glhModel.
×
296
         
×
297
        frequencies := gitAnalyzer
×
298
                               onProject: (itsProjects at: projectId);
×
299
                               analyseCommitFrequencySince: sinceDate
×
300
                               until: untilDate. 
×
301
        
×
302
        "complete each commit "
×
303
        frequencies values flattened do: [ :commit |
×
304
                glhImporter completeImportedCommit: commit.
×
305
                 ].
×
306
        
×
307
        "Filter the associations in the 'frequencies' collection, removing any commits not created by the specified 'user'. "
×
308
        frequencies associations do: [ :assoc |
×
309
                |commits| 
×
310
                commits := assoc value.
×
311
                assoc value: (commits reject: [ :commit | commit commitCreator ~= user ]). 
×
312
        ].
×
313
        
×
314
        ^ frequencies 
×
315
]
×
316

×
317
{ #category : #metrics }
×
318
GitMetric4User >> commitsProducedOnProject: aProjectId since: since until: until overA: aWeekOrMonthOrYear [
×
319
        "'aWeekOrMonthOrYear' should be the class of Week, Month or Year"
×
320

×
321
        "self commitFrequencyOnProject: 6462 since: (Date today - 60 day) until: (Date today) overA: Week. "
×
322

×
323
        | frequency aggregatedFrequencies |
×
324
        aggregatedFrequencies := self setupGroupedDateFrom: since to: until  over: aWeekOrMonthOrYear.
×
325
        
×
326
        frequency := self
×
327
                             commitsProducedOnProject: aProjectId
×
328
                             since: since
×
329
                             until: until.
×
330

×
331

×
332
        frequency associations do: [ :assoc |
×
333
                | date commits overDate |
×
334
                date := assoc key.
×
335
                commits := assoc value.
×
336

×
337
                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 "
×
338
                        overDate := self transformDate: date to: aWeekOrMonthOrYear.
×
339
                        aggregatedFrequencies
×
340
                                at: overDate printString
×
341
                                ifPresent: [ :collection | collection addAll: commits ]
×
342
                                ifAbsentPut: [ commits ] ] ].
×
343

×
344
        ^ aggregatedFrequencies
×
345
]
×
346

×
347
{ #category : #churn }
×
348
GitMetric4User >> delayUntilFirstChurnSince: since until: until overA: aDateWeekMonthOrYear [
×
349

×
350
        | commits groupedByDate res avg |
×
351
        
×
352
                ('GitMetric4User: delay until first churn') recordInfo.        
×
353
        
×
354
        groupedByDate := self
×
355
                                 setupGroupedDateFrom: since
×
356
                                 to: until
×
357
                                 over: aDateWeekMonthOrYear.
×
358

×
359
        commits := self
×
360
                           loadCommitOfProjects: itsProjects keys
×
361
                           since: since
×
362
                           until: until.
×
363

×
364
        "class commit by dates, filter none user commits"
×
365
        commits do: [ :commit |
×
366
                commit commitCreator = user ifTrue: [
×
367
                        | overDate |
×
368
                        overDate := self
×
369
                                            transformDate: commit created_at
×
370
                                            to: aDateWeekMonthOrYear.
×
371

×
372
                        groupedByDate
×
373
                                at: overDate printString
×
374
                                ifPresent: [ :arrayOfCommits | arrayOfCommits add: commit ]
×
375
                                ifAbsentPut: [
×
376
                                        OrderedCollection new
×
377
                                                add: commit;
×
378
                                                yourself ] ] ].
×
379

×
380

×
381

×
382
        res := groupedByDate collect: [ :commits4Date |
×
383
                       | durationFromA2B |
×
384
                       commits4Date collect: [ :commitA |
×
385
                               | commitB |
×
386
                               commitB := GitAnalyzer new
×
387
                                                  glhImporter: glhImporter;
×
388
                                                  onModel: glhModel;
×
389
                                                  fromCommit: commitA;
×
390
                                                                                maxChildCommit: 5;
×
391
                                                  analyseAmandment.
×
392

×
393
                               durationFromA2B := commitB
×
394
                                                          ifNil: [ 0 ]
×
395
                                                          ifNotNil: [
×
396
                                                          commitB created_at - commitA created_at ].
×
397
                               durationFromA2B ] ].
×
398

×
399

×
400

×
401
        res := res collect: [ :durationsByDate |
×
402
                       | filtered |
×
403
                       filtered := durationsByDate reject: [ :value | value = 0 ].
×
404
                       filtered isEmpty
×
405
                               ifTrue: [ nil ]
×
406
                               ifFalse: [
×
407
                               (filtered sum: [ :v | v asDuration ]) / filtered size ] ].
×
408

×
409
        res := res reject: #isNil.
×
410
        
×
411
        res ifEmpty: [ avg:= nil ] ifNotEmpty: [ avg := res values sum / res keys size. ].
×
412

×
413

×
414
        ^ {
×
415
                  (#avgDelay -> avg).
×
416
                  (#overEach -> aDateWeekMonthOrYear name).
×
417
                  (#forOver -> (groupedByDate keys size printString
×
418
                    , aDateWeekMonthOrYear printString)).
×
419
                  (#details -> groupedByDate) } asDictionary
×
420
]
×
421

×
422
{ #category : #'as yet unclassified' }
×
423
GitMetric4User >> findUserNamed: aUsername [
×
424

×
425
        user := glhImporter importUserByUsername: aUsername.
×
426
        ^ user
×
427
]
×
428

×
429
{ #category : #accessing }
×
430
GitMetric4User >> glhImporter: aGLPHModelImporter [ 
×
431
        glhImporter := aGLPHModelImporter
×
432
]
×
433

×
434
{ #category : #initialization }
×
435
GitMetric4User >> initialize [
×
436

×
437
        user := GLHUser new.
×
438
        itsProjects := Dictionary new.
×
439
        itsCommits := Dictionary new.
×
440
        itsGroups := Dictionary new.
×
441
        itsMergeRequests := Dictionary new
×
442
]
×
443

×
444
{ #category : #churn }
×
445
GitMetric4User >> loadCommitOfProjects: aCollection since: aTimespan [
×
446
        |commits|
×
447
        
×
448
        commits := (aCollection collect: [ :id |
×
449
                 glhImporter
×
450
                        importCommitsOProject: (itsProjects at: id)
×
451
                        since: aTimespan
×
452
                        until: nil ]) flattened.
×
453

×
454
        commits do: [ :commit |
×
455
                glhImporter completeImportedCommit: commit. 
×
456
                 ].
×
457

×
458
        ^ self userCommits.
×
459
]
×
460

×
461
{ #category : #churn }
×
462
GitMetric4User >> loadCommitOfProjects: aCollection since: since until: until [
×
463

×
464
        | allCommits |
×
465
        allCommits := itsCommits
×
466
                              at: since printString , '-' , until printString
×
467
                              ifPresent: [ :c | c ]
×
468
                              ifAbsentPut: [
×
469
                                      | commits |
×
470
                                                        commits :=   (aCollection collect: [ :id |
×
471
                                                                                                |project|
×
472
                                                                                                
×
473
                                                                                                project := (itsProjects at: id).
×
474
                                                                                                 project repository commits ifEmpty: [glhImporter
×
475
                                                                  importCommitsOProject:
×
476
                                                                  (project)
×
477
                                                                  since: since
×
478
                                                                  until: until].
×
479
                                                           ]
×
480
                                
×
481
                                ). 
×
482
                                     " commits := commits flatCollect: [ :c | c ]."
×
483
                                      commits ].
×
484

×
485
        allCommits := allCommits flatten.
×
486
        allCommits do: [ :commit |
×
487
                glhImporter completeImportedCommit: commit ].
×
488

×
489
        glhImporter chainsCommitsFrom: allCommits.
×
490

×
491
        ^ allCommits
×
492
]
×
493

×
494
{ #category : #churn }
×
495
GitMetric4User >> loadMergeRequestsOfProjects: aCollection since: since until: until [
×
496

×
497
        | allMr |
×
498
        itsMergeRequests ifNil: [ itsMergeRequests := Dictionary new ].
×
499

×
500

×
501

×
502
        allMr := itsMergeRequests
×
503
                         at: since printString , '-' , until printString
×
504
                         ifPresent: [ :c | c ]
×
505
                         ifAbsentPut: [
×
506
                                 | mr |
×
507
                                 mr := (aCollection collect: [ :id |
×
508
                                                glhImporter
×
509
                                                        importMergeRequests: (itsProjects at: id)
×
510
                                                        since: since
×
511
                                                        until: until ]) flattened.
×
512
                                " mr := mr flatCollect: [ :c | c ]."
×
513
                                 mr ].
×
514

×
515

×
516
        ^ allMr
×
517
]
×
518

×
519
{ #category : #loading }
×
520
GitMetric4User >> loadProjects: projectIds [
×
521

×
522
        projectIds do: [ :id |
×
523
                
×
524
                itsProjects at: id ifAbsentPut: [ glhImporter importProject: id ] ].
×
525

×
526
        ^ itsProjects
×
527
]
×
528

×
529
{ #category : #metrics }
×
530
GitMetric4User >> mergeRequestDurationSince: since until: until overA: aDateWeekMonthOrYear [
×
531

×
532
        | mergeRequest res groupedByDate filterGroups avg |
×
533
        groupedByDate := self
×
534
                                 setupGroupedDateFrom: since
×
535
                                 to: until
×
536
                                 over: aDateWeekMonthOrYear.
×
537

×
538
        gitAnalyzer := GitAnalyzer new
×
539
                               glhImporter: glhImporter;
×
540
                               onModel: glhModel.
×
541

×
542
        mergeRequest := self
×
543
                                loadMergeRequestsOfProjects: itsProjects keys
×
544
                                since: since
×
545
                                until: until.
×
546
        
×
547

×
548
        mergeRequest ifEmpty: [
×
549
                ^ {
×
550
                          (#avgDuration -> nil).
×
551
                          (#overEach -> aDateWeekMonthOrYear name).
×
552
                          (#forOver -> (groupedByDate keys size printString
×
553
                            , aDateWeekMonthOrYear printString)).
×
554
                          (#totalMergeRequest -> 0).
×
555
                          (#details -> nil) } asDictionary ].
×
556

×
557
        res := mergeRequest collect: [ :mr |
×
558
                       gitAnalyzer analyseMergeResquestValidation: mr ].
×
559

×
560

×
561
        res do: [ :dic |
×
562
                | overDate |
×
563
                overDate := self
×
564
                                    transformDate: (dic at: #created_at)
×
565
                                    to: aDateWeekMonthOrYear.
×
566

×
567
                groupedByDate
×
568
                        at: overDate printString
×
569
                        ifPresent: [ :durations | durations add: (dic at: #duration) ]
×
570
                        ifAbsentPut: [
×
571
                                OrderedCollection new
×
572
                                        add: (dic at: #duration);
×
573
                                        yourself ] ].
×
574

×
575

×
576
        filterGroups := groupedByDate reject: [ :array | array isEmpty ].
×
577

×
578
        filterGroups associations do: [ :assoc |
×
579
                | sum denominator |
×
580
                denominator := assoc value size.
×
581

×
582
                sum := assoc value sum: [ :v |
×
583
                               v ifNil: [
×
584
                                       denominator := denominator - 1.
×
585
                                       0 asDuration ] ].
×
586
                denominator = 0 ifTrue: [ denominator := 1 ].
×
587

×
588
                filterGroups at: assoc key put: sum / denominator ].
×
589

×
590

×
591
        filterGroups keys
×
592
                ifEmpty: [ avg := 0 ]
×
593
                ifNotEmpty: [
×
594
                avg := filterGroups values sum / filterGroups keys size ].
×
595

×
596

×
597
        ^ {
×
598
                  (#avgDuration -> avg).
×
599
                  (#overEach -> aDateWeekMonthOrYear name).
×
600
                  (#forOver -> (groupedByDate keys size printString
×
601
                    , aDateWeekMonthOrYear printString)).
×
602
                  (#totalMergeRequest -> mergeRequest size).
×
603
                  (#details -> groupedByDate) } asDictionary
×
604
]
×
605

×
606
{ #category : #setup }
×
607
GitMetric4User >> setupGroupedDateFrom: since to: until over: aDateWeekMonthOrYear [
×
608

×
609
        | groupedByDate start end over increment|
×
610
        groupedByDate := OrderedDictionary new.
×
611

×
612
        increment := 1.
×
613
        start := self transformDate: since to: aDateWeekMonthOrYear.
×
614
        end := self transformDate: until to: aDateWeekMonthOrYear.
×
615

×
616
        groupedByDate
×
617
                at: start printString
×
618
                ifAbsentPut: [ OrderedCollection new ].
×
619
        
×
620
        over := aDateWeekMonthOrYear name asLowercase asSymbol.
×
621
                over = #date ifTrue: [ over := #day ].
×
622
                over = #month ifTrue: [ increment := 32. over := #day ].
×
623
                 
×
624

×
625
        [ groupedByDate keys last asDateAndTime < end ] whileTrue: [
×
626
                | index  |
×
627
                index := groupedByDate keys last asDateAndTime + (increment perform: over).
×
628
                index := self transformDate: index to: aDateWeekMonthOrYear.
×
629
                groupedByDate
×
630
                        at: index printString
×
631
                        ifAbsentPut: [ OrderedCollection new ] ].
×
632
        
×
633
        
×
634
        over = #day ifTrue: [ 
×
635
                groupedByDate keys do: [ :date |
×
636
                        |aWeekday|
×
637
                         aWeekday := date asDate weekday. 
×
638
                        ((aWeekday =  #Sunday) or: [ aWeekday = #Saturday ] )ifTrue: [ 
×
639
                                groupedByDate removeKey: date. 
×
640
                                 ] 
×
641
                         ].
×
642
                 ].
×
643
        
×
644

×
645
        groupedByDate
×
646
                at: end printString
×
647
                ifAbsentPut: [ OrderedCollection new ].
×
648

×
649
        ^ groupedByDate
×
650
]
×
651

×
652
{ #category : #'as yet unclassified' }
×
653
GitMetric4User >> transformDate: date to: aWeekOrMonthOrYear [
×
654

×
655
        aWeekOrMonthOrYear = Month ifTrue: [ ^ date asDate month asDate ].
×
656

×
657
        ^ (date asDate perform: ('as' , aWeekOrMonthOrYear name) asSymbol)
×
658
                  asDate
×
659
]
×
660

×
661
{ #category : #accessing }
×
662
GitMetric4User >> user [
×
663
        ^ user
×
664
]
×
665

×
666
{ #category : #accessing }
×
667
GitMetric4User >> user: anUser [
×
668
        user := anUser. 
×
669
]
×
670

×
671
{ #category : #accessing }
×
672
GitMetric4User >> userCommits [
×
673
        ^ user commits
×
674
]
×
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