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

moosetechnology / GitProjectHealth / 13857031877

14 Mar 2025 12:55PM UTC coverage: 68.041% (+0.8%) from 67.231%
13857031877

push

github

web-flow
Merge pull request #152 from moosetechnology/metric-comment-lines-by-projects

add total comment added in project (average by unit scale) + tests

7564 of 8847 new or added lines in 94 files covered. (85.5%)

12508 of 18383 relevant lines covered (68.04%)

0.68 hits per line

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

92.98
/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
        "Filtrer les merge requests pour ne garder que celles qui ont une date de clĂ´ture (closed_at) et un statut 'closed'"
1✔
16
     projectMergeRequests := projectMergeRequests select: [ :mr | 
1✔
17
    (mr closed_at) notNil and: [(mr state) = 'closed'] ]. 
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: #closed_at) to: over.
1✔
31

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

1✔
36
        "deleting the empty array (merge request that are not closed )"
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
ClosedMergeRequestDurationProjectMetric >> description [
×
NEW
58

×
NEW
59
        ^ 'closed merge request  duration (second)'
×
NEW
60
]
×
61

62
{ #category : #loading }
63
ClosedMergeRequestDurationProjectMetric >> 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 · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc