Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(metrics): number of closed merge requests #39

Merged
merged 5 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 39 additions & 26 deletions src/GitLabHealth-Model-Analysis/AnalysisReport.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ Class {
'delayUntilFirstChurn',
'numberOfProjectWithCommit',
'averageTimeBetweenCommits',
'averageNumberOfOpenMergeRequest',
'averageNumberOfMergedMergeRequest'
'numberOfOpenMergeRequests',
'numberOfMergedMergeRequest',
'numberOfClosedMergeRequests'
],
#category : #'GitLabHealth-Model-Analysis'
}
Expand All @@ -25,30 +26,6 @@ AnalysisReport class >> isVoyageRoot [
^true
]

{ #category : #accessing }
AnalysisReport >> averageNumberOfMergedMergeRequest [

^ averageNumberOfMergedMergeRequest
]

{ #category : #accessing }
AnalysisReport >> averageNumberOfMergedMergeRequest: anObject [

averageNumberOfMergedMergeRequest := anObject
]

{ #category : #accessing }
AnalysisReport >> averageNumberOfOpenMergeRequest [

^ averageNumberOfOpenMergeRequest
]

{ #category : #accessing }
AnalysisReport >> averageNumberOfOpenMergeRequest: anObject [

averageNumberOfOpenMergeRequest := anObject
]

{ #category : #accessing }
AnalysisReport >> averageTimeBetweenCommits [

Expand Down Expand Up @@ -145,6 +122,42 @@ AnalysisReport >> mergeRequestDuration: anObject [
mergeRequestDuration := anObject
]

{ #category : #accessing }
AnalysisReport >> numberOfClosedMergeRequests [

^ numberOfClosedMergeRequests
]

{ #category : #accessing }
AnalysisReport >> numberOfClosedMergeRequests: anObject [

numberOfClosedMergeRequests := anObject
]

{ #category : #accessing }
AnalysisReport >> numberOfMergedMergeRequest [

^ numberOfMergedMergeRequest
]

{ #category : #accessing }
AnalysisReport >> numberOfMergedMergeRequest: anObject [

numberOfMergedMergeRequest := anObject
]

{ #category : #accessing }
AnalysisReport >> numberOfOpenMergeRequests [

^ numberOfOpenMergeRequests
]

{ #category : #accessing }
AnalysisReport >> numberOfOpenMergeRequests: anObject [

numberOfOpenMergeRequests := anObject
]

{ #category : #accessing }
AnalysisReport >> numberOfProjectWithCommit [

Expand Down
83 changes: 68 additions & 15 deletions src/GitLabHealth-Model-Analysis/GitMetric4User.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ GitMetric4User >> foundSuccessorOf: userCommits andCompleteImportForMax: commitL
{ #category : #analysis }
GitMetric4User >> generateAnalysisForPeriod: period over: aDateWeekMonthOrYear withMaxCommitWindows: maxCommitWindow [

| contribution commitFrequency commentContribution mergeRequestDuration codeChurn delayUntilFirstChurn averageTimeBetweenCommits numberOfProjectWithCommit until since numberOfOpenMergeRequest numberOfMergedMergeRequest |
| contribution commitFrequency commentContribution mergeRequestDuration codeChurn delayUntilFirstChurn averageTimeBetweenCommits numberOfProjectWithCommit until since numberOfOpenMergeRequests numberOfMergedMergeRequests numberOfClosedMergeRequests |
since := period at: #since.
until := period at: #until.

Expand Down Expand Up @@ -619,15 +619,22 @@ GitMetric4User >> generateAnalysisForPeriod: period over: aDateWeekMonthOrYear w
until: until
overA: aDateWeekMonthOrYear.

numberOfOpenMergeRequest := self
numberOfOpenMergeRequestSince: since
until: until
overA: aDateWeekMonthOrYear.
numberOfOpenMergeRequests := self
numberOfOpenMergeRequestsSince: since
until: until
overA: aDateWeekMonthOrYear.

numberOfMergedMergeRequests := self
numberOfMergedMergeRequestsSince:
since
until: until
overA: aDateWeekMonthOrYear.

numberOfMergedMergeRequest := self
numberOfMergedMergeRequestSince: since
until: until
overA: aDateWeekMonthOrYear.
numberOfClosedMergeRequests := self
numberOfClosedMergeRequestSince:
since
until: until
overA: aDateWeekMonthOrYear.

^ AnalysisReport new
username: self user name;
Expand All @@ -644,10 +651,9 @@ GitMetric4User >> generateAnalysisForPeriod: period over: aDateWeekMonthOrYear w
(numberOfProjectWithCommit at: #average);
averageTimeBetweenCommits:
(averageTimeBetweenCommits at: #average);
averageNumberOfOpenMergeRequest:
(numberOfOpenMergeRequest at: #average);
averageNumberOfMergedMergeRequest:
(numberOfMergedMergeRequest at: #average)
numberOfOpenMergeRequests: (numberOfOpenMergeRequests at: #average);
numberOfMergedMergeRequest: (numberOfMergedMergeRequests at: #average);
numberOfClosedMergeRequests: (numberOfClosedMergeRequests at: #average)
]

{ #category : #initialization }
Expand Down Expand Up @@ -773,7 +779,51 @@ GitMetric4User >> mergeRequestDurationSince: since until: until overA: aDateWeek
]

{ #category : #'metrics - merge request' }
GitMetric4User >> numberOfMergedMergeRequestSince: since until: until overA: aDateWeekMonthOrYear [
GitMetric4User >> numberOfClosedMergeRequestSince: since until: until overA: aDateWeekMonthOrYear [

| groupedByDate userMergeRequests dateOver average userClosedMergeRequests |
groupedByDate := self
setupGroupedDateFrom: since
to: until
over: aDateWeekMonthOrYear.

userMergeRequests := self
loadItsMergeRequestsSince: since
until: until.

userClosedMergeRequests := userMergeRequests select: [
:userMergeRequest |
userMergeRequest merged_at isNil and:
userMergeRequest state = 'closed' ].

userClosedMergeRequests do: [ :userMergeRequest |
dateOver := self
transformDate: userMergeRequest created_at
to: aDateWeekMonthOrYear.

groupedByDate
at: dateOver printString
ifPresent: [ :value | value add: userMergeRequest ] ].


groupedByDate := groupedByDate collect: [ :group | group size ].


average := groupedByDate
ifEmpty: [ 0 ]
ifNotEmpty: [ groupedByDate average ].

^ {
(#overEach -> aDateWeekMonthOrYear name).
(#forOver -> (groupedByDate keys size printString
, aDateWeekMonthOrYear printString)).
(#average -> average asFloat).
(#details -> groupedByDate).
(#userMergeRequests -> userMergeRequests size) } asDictionary
]

{ #category : #'metrics - merge request' }
GitMetric4User >> numberOfMergedMergeRequestsSince: since until: until overA: aDateWeekMonthOrYear [

| groupedByDate userMergeRequests dateOver average userMergedMergeRequests |
groupedByDate := self
Expand All @@ -783,9 +833,11 @@ GitMetric4User >> numberOfMergedMergeRequestSince: since until: until overA: aDa
userMergeRequests := self
loadItsMergeRequestsSince: since
until: until.

userMergedMergeRequests := userMergeRequests select: [
:userMergeRequest |
userMergeRequest merged_at isNotNil ].

userMergedMergeRequests do: [ :userMergeRequest |
dateOver := self
transformDate: userMergeRequest created_at
Expand All @@ -794,6 +846,7 @@ GitMetric4User >> numberOfMergedMergeRequestSince: since until: until overA: aDa
at: dateOver printString
ifPresent: [ :value | value add: userMergeRequest ] ].
groupedByDate := groupedByDate collect: [ :group | group size ].

average := groupedByDate
ifEmpty: [ 0 ]
ifNotEmpty: [ groupedByDate average ].
Expand All @@ -807,7 +860,7 @@ GitMetric4User >> numberOfMergedMergeRequestSince: since until: until overA: aDa
]

{ #category : #'metrics - merge request' }
GitMetric4User >> numberOfOpenMergeRequestSince: since until: until overA: aDateWeekMonthOrYear [
GitMetric4User >> numberOfOpenMergeRequestsSince: since until: until overA: aDateWeekMonthOrYear [

| groupedByDate userMergeRequests dateOver average |
groupedByDate := self
Expand Down
34 changes: 19 additions & 15 deletions src/GitLabHealth-Model-Analysis/GitMetricExporter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,6 @@ GitMetricExporter >> exportInCSV [
addColumnForQuery: [ :analysis | analysis commentContribution ]
withName: 'comment contribution (avg)' asSymbol.

"merge Request Duration "
exportBrowserModel
addColumnForQuery: [ :analysis | analysis mergeRequestDuration ]
withName: 'merge Request Duration ' asSymbol.

"code churn"
exportBrowserModel
addColumnForQuery: [ :analysis | analysis codeChurn ]
Expand All @@ -207,23 +202,32 @@ GitMetricExporter >> exportInCSV [
addColumnForQuery: [ :analysis | analysis numberOfProjectWithCommit ]
withName: 'number of project with min 1 commit of user' asSymbol.

"merge Request Duration "
exportBrowserModel
addColumnForQuery: [ :analysis | analysis mergeRequestDuration ]
withName: 'merge Request Duration ' asSymbol.

"average time between commits"
exportBrowserModel
addColumnForQuery: [ :analysis | analysis averageTimeBetweenCommits ]
withName: 'average time between commits' asSymbol.

"average number of open merge request"
"number of open merge request"
exportBrowserModel
addColumnForQuery: [ :analysis |
analysis averageNumberOfOpenMergeRequest ]
withName: 'average number of open merge request' asSymbol.


"average number of merged merge request"
addColumnForQuery: [ :analysis | analysis numberOfOpenMergeRequests ]
withName: 'number of open merge request' asSymbol.


"number of merged merge request"
exportBrowserModel
addColumnForQuery: [ :analysis | analysis numberOfMergedMergeRequest ]
withName: 'number of merged merge request' asSymbol.

"number of merge requests closed and not merged"
exportBrowserModel
addColumnForQuery: [ :analysis |
analysis averageNumberOfMergedMergeRequest ]
withName: 'average number of merged merge request' asSymbol.
addColumnForQuery: [ :analysis | analysis numberOfClosedMergeRequests ]
withName: 'number of merge requests closed and not merged' asSymbol.


file := self constructFilePath: over.
file writeStreamDo: [ :aStream |
Expand Down
Loading