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

moosetechnology / GitProjectHealth / 13807399403

12 Mar 2025 08:58AM UTC coverage: 66.731% (+0.2%) from 66.508%
13807399403

Pull #145

github

web-flow
Merge 41a250ee3 into 2c2d8c5e1
Pull Request #145: Code addition merge rerquest project metric

6833 of 8097 new or added lines in 90 files covered. (84.39%)

1 existing line in 1 file now uncovered.

11746 of 17602 relevant lines covered (66.73%)

0.67 hits per line

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

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

7
{ #category : #calculating }
8
ClosedMergeRequestDurationProjectMetric >> 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: #closed_at) to: over.
1✔
27

1✔
28
                groupedByDate
1✔
29
                        at: overDate printString
1✔
30
                        ifPresent: [ :durations | durations add: (dic at: #close_duration) ] ].
1✔
31

1✔
32
        "deleting the empty array (merge request that are not closed )"
1✔
33
        filterGroups := groupedByDate reject: [ :array | array isEmpty ].
1✔
34
        "Check if filterGroups is empty before proceeding to avoid merge request out of analyse periode "
1✔
35
        filterGroups isEmpty ifTrue: [ ^ 0 ].
1✔
36

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

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

1✔
47
                filterGroups at: assoc key put: sum / denominator ].
1✔
48

1✔
49
        ^ filterGroups average asSeconds
1✔
50
]
1✔
51

52
{ #category : #accessing }
NEW
53
ClosedMergeRequestDurationProjectMetric >> description [
×
NEW
54

×
NEW
55
        ^ 'closed merge request  duration (second)'
×
NEW
56
]
×
57

58
{ #category : #loading }
59
ClosedMergeRequestDurationProjectMetric >> load [
1✔
60

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

© 2025 Coveralls, Inc