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

moosetechnology / GitProjectHealth / 13563141192

27 Feb 2025 09:29AM UTC coverage: 64.054% (+1.3%) from 62.725%
13563141192

Pull #137

github

web-flow
Merge b0354cfb8 into 29b562512
Pull Request #137: WIP : merge request duration project metric

607 of 611 new or added lines in 8 files covered. (99.35%)

53 existing lines in 6 files now uncovered.

10585 of 16525 relevant lines covered (64.05%)

0.64 hits per line

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

92.73
/src/GitLabHealth-Model-Analysis/OpenedMergeRequestDurationProjectMetric.class.st
1
Class {
2
        #name : #OpenedMergeRequestDurationProjectMetric,
3
        #superclass : #ProjectMetric,
4
        #category : #'GitLabHealth-Model-Analysis'
5
}
6

7
{ #category : #calculating }
8
OpenedMergeRequestDurationProjectMetric >> calculate [
1✔
9

1✔
10
        | groupedByDate gitAnalyzer mergeRequestsValidation filterGroups  |
1✔
11
        projectMergeRequests ifNil: [ self load ].
1✔
12
        
1✔
13
        groupedByDate := self setupGroupedDate.
1✔
14

1✔
15
        projectMergeRequests ifEmpty: [ ^ nil ].
1✔
16

1✔
17
        gitAnalyzer := GitAnalyzer new.
1✔
18

1✔
19
        mergeRequestsValidation := projectMergeRequests  collect: [ :mr |
1✔
20
                                           gitAnalyzer
1✔
21
                                                   analyseMergeResquestValidation: mr ].
1✔
22

1✔
23

1✔
24
        mergeRequestsValidation do: [ :dic |
1✔
25
                | overDate |
1✔
26
                overDate := self transformDate: (dic at: #created_at) to: over.
1✔
27

1✔
28
                groupedByDate
1✔
29
                        at: overDate printString
1✔
30
                        ifPresent: [ :durations | durations add: (dic at: #open_duration) ]
1✔
31
                        ifAbsentPut: [
1✔
32
                                OrderedCollection new
1✔
33
                                        add: (dic at: #open_duration);
1✔
34
                                        yourself ] ].
1✔
35

1✔
36
     "deleting the empty array"
1✔
37
        filterGroups := groupedByDate reject: [ :array | array isEmpty ].
1✔
38

1✔
39
        filterGroups associations do: [ :assoc |
1✔
40
                | sum denominator |
1✔
41
                denominator := assoc value size.
1✔
42

1✔
43
                sum := assoc value sum: [ :v |
1✔
44
                               v ifNil: [
1✔
45
                                       denominator := denominator - 1.
1✔
46
                                       0 asDuration ] ].
1✔
47
                denominator = 0 ifTrue: [ denominator := 1 ].
1✔
48

1✔
49
                filterGroups at: assoc key put: sum / denominator ].
1✔
50

1✔
51
        ^ filterGroups average asSeconds 
1✔
52
]
1✔
53

54
{ #category : #accessing }
NEW
55
OpenedMergeRequestDurationProjectMetric >> description [
×
NEW
56

×
NEW
57
        ^ ' duration of a Merge Request since it creation  (second)'
×
NEW
58
]
×
59

60
{ #category : #loading }
61
OpenedMergeRequestDurationProjectMetric >> load [
1✔
62

1✔
63
        projectMergeRequests := self
1✔
64
                              loadMergeRequestsSince:  (period at: #since)
1✔
65
                              until:  (period at: #until)
1✔
66
]
1✔
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