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 merge requests without review #40

Merged
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
15 changes: 14 additions & 1 deletion src/GitLabHealth-Model-Analysis/AnalysisReport.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ Class {
'averageTimeBetweenCommits',
'numberOfOpenMergeRequests',
'numberOfMergedMergeRequest',
'numberOfClosedMergeRequests'
'numberOfClosedMergeRequests',
'numberOfMergeRequestsWithoutReview'
],
#category : #'GitLabHealth-Model-Analysis'
}
Expand Down Expand Up @@ -134,6 +135,18 @@ AnalysisReport >> numberOfClosedMergeRequests: anObject [
numberOfClosedMergeRequests := anObject
]

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

^ numberOfMergeRequestsWithoutReview
]

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

numberOfMergeRequestsWithoutReview := anObject
]

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

Expand Down
78 changes: 74 additions & 4 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 numberOfOpenMergeRequests numberOfMergedMergeRequests numberOfClosedMergeRequests |
| contribution commitFrequency commentContribution mergeRequestDuration codeChurn delayUntilFirstChurn averageTimeBetweenCommits numberOfProjectWithCommit until since numberOfOpenMergeRequests numberOfMergedMergeRequests numberOfClosedMergeRequests numberOfMergeRequestWithoutReview |
since := period at: #since.
until := period at: #until.

Expand Down Expand Up @@ -636,6 +636,12 @@ GitMetric4User >> generateAnalysisForPeriod: period over: aDateWeekMonthOrYear w
until: until
overA: aDateWeekMonthOrYear.

numberOfMergeRequestWithoutReview := self
numberOfMergeRequestsMergedWithoutReviewSince:
since
until: until
overA: aDateWeekMonthOrYear.

^ AnalysisReport new
username: self user name;
period: period;
Expand All @@ -651,9 +657,13 @@ GitMetric4User >> generateAnalysisForPeriod: period over: aDateWeekMonthOrYear w
(numberOfProjectWithCommit at: #average);
averageTimeBetweenCommits:
(averageTimeBetweenCommits at: #average);
numberOfOpenMergeRequests: (numberOfOpenMergeRequests at: #average);
numberOfMergedMergeRequest: (numberOfMergedMergeRequests at: #average);
numberOfClosedMergeRequests: (numberOfClosedMergeRequests at: #average)
numberOfOpenMergeRequests:
(numberOfOpenMergeRequests at: #average);
numberOfMergedMergeRequest:
(numberOfMergedMergeRequests at: #average);
numberOfClosedMergeRequests:
(numberOfClosedMergeRequests at: #average);
numberOfMergeRequestsWithoutReview: (numberOfMergeRequestWithoutReview at: #average).
]

{ #category : #initialization }
Expand Down Expand Up @@ -822,6 +832,66 @@ GitMetric4User >> numberOfClosedMergeRequestSince: since until: until overA: aDa
(#userMergeRequests -> userMergeRequests size) } asDictionary
]

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

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

userMergeRequests := self
loadItsMergeRequestsSince: since
until: until.

mergedMergeRequest := userMergeRequests select: [ :mr |
mr merged_at isNotNil ].


noVerificationMergeRequests := mergedMergeRequest select: [
:userMergeRequest |
| validation |
glhImporter
importMergeResquestMerger:
userMergeRequest.

validation := gitAnalyzer
analyseMergeResquestValidation:
userMergeRequest.

userMergeRequest merge_user
= userMergeRequest author and:
(validation at: #duration)
< 1 minutes ].


noVerificationMergeRequests 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 [

Expand Down
15 changes: 12 additions & 3 deletions src/GitLabHealth-Model-Analysis/GitMetricExporter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -214,21 +214,30 @@ GitMetricExporter >> exportInCSV [

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


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

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


"number of merge requests withour review"
exportBrowserModel
addColumnForQuery: [ :analysis |
analysis numberOfMergeRequestsWithoutReview ]
withName: 'number of merge requests without review' asSymbol.


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