From efff1d503d5c9bdf2cc9cee7ae6cd8ba9af525b8 Mon Sep 17 00:00:00 2001 From: Kilian B <60846047+knowbased@users.noreply.github.com> Date: Tue, 20 Aug 2024 16:20:35 +0200 Subject: [PATCH] feat: add number of merge request without review in analysisReport and csv export --- .../AnalysisReport.class.st | 15 +++- .../GitMetric4User.class.st | 78 ++++++++++++++++++- .../GitMetricExporter.class.st | 15 +++- 3 files changed, 100 insertions(+), 8 deletions(-) diff --git a/src/GitLabHealth-Model-Analysis/AnalysisReport.class.st b/src/GitLabHealth-Model-Analysis/AnalysisReport.class.st index 8f6a2f6..cf7b3fc 100644 --- a/src/GitLabHealth-Model-Analysis/AnalysisReport.class.st +++ b/src/GitLabHealth-Model-Analysis/AnalysisReport.class.st @@ -16,7 +16,8 @@ Class { 'averageTimeBetweenCommits', 'numberOfOpenMergeRequests', 'numberOfMergedMergeRequest', - 'numberOfClosedMergeRequests' + 'numberOfClosedMergeRequests', + 'numberOfMergeRequestsWithoutReview' ], #category : #'GitLabHealth-Model-Analysis' } @@ -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 [ diff --git a/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st b/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st index cb20def..de01d63 100644 --- a/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st +++ b/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st @@ -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. @@ -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; @@ -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 } @@ -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 [ diff --git a/src/GitLabHealth-Model-Analysis/GitMetricExporter.class.st b/src/GitLabHealth-Model-Analysis/GitMetricExporter.class.st index af7b0ec..8fd5ca0 100644 --- a/src/GitLabHealth-Model-Analysis/GitMetricExporter.class.st +++ b/src/GitLabHealth-Model-Analysis/GitMetricExporter.class.st @@ -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