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

moosetechnology / GitProjectHealth / 13836317433

13 Mar 2025 01:53PM UTC coverage: 67.231% (+0.3%) from 66.98%
13836317433

Pull #149

github

web-flow
Merge 679554b3f into 95d73a529
Pull Request #149: Fix mergerequest (closed , merged) duration project metric

2143 of 3405 new or added lines in 52 files covered. (62.94%)

12043 of 17913 relevant lines covered (67.23%)

0.67 hits per line

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

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

7
{ #category : #calculating }
8
MergedMergeRequestDurationProjectMetric >> 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
        "Filtrer les merge requests pour ne garder que celles qui ont une date de clĂ´ture (merged_at) et un statut 'merged'"
1✔
16
     projectMergeRequests := projectMergeRequests select: [ :mr | 
1✔
17
    (mr merged_at) notNil and: [(mr state) = 'merged'] ]. 
1✔
18

1✔
19
        projectMergeRequests ifEmpty: [ ^ nil ].
1✔
20

1✔
21
        gitAnalyzer := GitAnalyzer new.
1✔
22

1✔
23
        mergeRequestsValidation := projectMergeRequests collect: [ :mr |
1✔
24
                                           gitAnalyzer
1✔
25
                                                   analyseMergeResquestValidation: mr ].
1✔
26

1✔
27

1✔
28
        mergeRequestsValidation do: [ :dic |
1✔
29
                | overDate |
1✔
30
                overDate := self transformDate: (dic at: #merged_at) to: over.
1✔
31

1✔
32
                groupedByDate
1✔
33
                        at: overDate printString
1✔
34
                        ifPresent: [ :durations | durations add: (dic at: #duration) ] ].
1✔
35

1✔
36
        "deleting the empty array (merge request that are not merged )"
1✔
37
        filterGroups := groupedByDate reject: [ :array | array isEmpty ].
1✔
38
        "Check if filterGroups is empty before proceeding to avoid merge request out of analyse periode "
1✔
39
        filterGroups isEmpty ifTrue: [ ^ 0 ].
1✔
40

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

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

1✔
51
                filterGroups at: assoc key put: sum / denominator ].
1✔
52

1✔
53
        ^ filterGroups average asSeconds
1✔
54
]
1✔
55

56
{ #category : #accessing }
NEW
57
MergedMergeRequestDurationProjectMetric >> description [
×
NEW
58

×
NEW
59
        ^ 'Merged Merge Request duration  (second)'
×
NEW
60
]
×
61

62
{ #category : #loading }
63
MergedMergeRequestDurationProjectMetric >> load [
1✔
64

1✔
65
        projectMergeRequests := self
1✔
66
                              loadMergeRequestsSince:  (period at: #since)
1✔
67
                              until:  (period at: #until)
1✔
68
]
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc