From 9fef5dce57b89d19bc29724b857dd04323420316 Mon Sep 17 00:00:00 2001 From: Kilian B <60846047+knowbased@users.noreply.github.com> Date: Tue, 20 Aug 2024 14:07:34 +0200 Subject: [PATCH 1/5] feat: add closedMergeRequestsSince:until:overA method --- .../GitMetric4User.class.st | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st b/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st index e4d2413..934710c 100644 --- a/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st +++ b/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st @@ -69,6 +69,50 @@ GitMetric4User >> averageTimeBetweenCommitSince: since until: until overA: aDate (#userCommits -> commits size) } asDictionary ] +{ #category : #'metrics - merge request' } +GitMetric4User >> closedMergeRequestSince: 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 : #churn } GitMetric4User >> codeChurnSince: since until: until onACommitWindowOf: commitLimit overA: aDateWeekMonthOrYear [ @@ -783,9 +827,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 @@ -794,6 +840,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 ]. From 63eeca0a784ad6c6684ee63022cbe9b35ca33f98 Mon Sep 17 00:00:00 2001 From: Kilian B <60846047+knowbased@users.noreply.github.com> Date: Tue, 20 Aug 2024 14:20:21 +0200 Subject: [PATCH 2/5] feat: add averageClosedMergeRequests in analysisReport and csv export --- .../AnalysisReport.class.st | 15 ++++++++++++++- .../GitMetric4User.class.st | 10 ++++++++-- .../GitMetricExporter.class.st | 11 +++++++++-- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/GitLabHealth-Model-Analysis/AnalysisReport.class.st b/src/GitLabHealth-Model-Analysis/AnalysisReport.class.st index 6125723..ef91438 100644 --- a/src/GitLabHealth-Model-Analysis/AnalysisReport.class.st +++ b/src/GitLabHealth-Model-Analysis/AnalysisReport.class.st @@ -15,7 +15,8 @@ Class { 'numberOfProjectWithCommit', 'averageTimeBetweenCommits', 'averageNumberOfOpenMergeRequest', - 'averageNumberOfMergedMergeRequest' + 'averageNumberOfMergedMergeRequest', + 'averageClosedMergeRequests' ], #category : #'GitLabHealth-Model-Analysis' } @@ -25,6 +26,18 @@ AnalysisReport class >> isVoyageRoot [ ^true ] +{ #category : #accessing } +AnalysisReport >> averageClosedMergeRequests [ + + ^ averageClosedMergeRequests +] + +{ #category : #accessing } +AnalysisReport >> averageClosedMergeRequests: anObject [ + + averageClosedMergeRequests := anObject +] + { #category : #accessing } AnalysisReport >> averageNumberOfMergedMergeRequest [ diff --git a/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st b/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st index 934710c..20c5a9c 100644 --- a/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st +++ b/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st @@ -615,7 +615,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 numberOfOpenMergeRequest numberOfMergedMergeRequest closedMergeRequests | since := period at: #since. until := period at: #until. @@ -673,6 +673,11 @@ GitMetric4User >> generateAnalysisForPeriod: period over: aDateWeekMonthOrYear w until: until overA: aDateWeekMonthOrYear. + closedMergeRequests := self + closedMergeRequestSince: since + until: until + overA: aDateWeekMonthOrYear. + ^ AnalysisReport new username: self user name; period: period; @@ -691,7 +696,8 @@ GitMetric4User >> generateAnalysisForPeriod: period over: aDateWeekMonthOrYear w averageNumberOfOpenMergeRequest: (numberOfOpenMergeRequest at: #average); averageNumberOfMergedMergeRequest: - (numberOfMergedMergeRequest at: #average) + (numberOfMergedMergeRequest at: #average); + averageClosedMergeRequests: (closedMergeRequests at: #average) ] { #category : #initialization } diff --git a/src/GitLabHealth-Model-Analysis/GitMetricExporter.class.st b/src/GitLabHealth-Model-Analysis/GitMetricExporter.class.st index 8274d62..c607633 100644 --- a/src/GitLabHealth-Model-Analysis/GitMetricExporter.class.st +++ b/src/GitLabHealth-Model-Analysis/GitMetricExporter.class.st @@ -217,13 +217,20 @@ GitMetricExporter >> exportInCSV [ addColumnForQuery: [ :analysis | analysis averageNumberOfOpenMergeRequest ] withName: 'average number of open merge request' asSymbol. - - + + "average number of merged merge request" exportBrowserModel addColumnForQuery: [ :analysis | analysis averageNumberOfMergedMergeRequest ] withName: 'average number of merged merge request' asSymbol. + + "Average number of merge requests closed and not merged" + exportBrowserModel + addColumnForQuery: [ :analysis | + analysis averageClosedMergeRequests ] + withName: 'average number of merge requests closed and not merged' asSymbol. + file := self constructFilePath: over. file writeStreamDo: [ :aStream | From bd8d46f066b546fa3e02a36fb654076dccd8c39c Mon Sep 17 00:00:00 2001 From: Kilian B <60846047+knowbased@users.noreply.github.com> Date: Tue, 20 Aug 2024 14:23:46 +0200 Subject: [PATCH 3/5] refactor: rename merge request metrics method --- .../GitMetric4User.class.st | 105 +++++++++--------- 1 file changed, 52 insertions(+), 53 deletions(-) diff --git a/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st b/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st index 20c5a9c..adbff4b 100644 --- a/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st +++ b/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st @@ -615,7 +615,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 closedMergeRequests | + | contribution commitFrequency commentContribution mergeRequestDuration codeChurn delayUntilFirstChurn averageTimeBetweenCommits numberOfProjectWithCommit until since closedMergeRequests openMergeRequests mergedMergeRequests | since := period at: #since. until := period at: #until. @@ -663,15 +663,15 @@ GitMetric4User >> generateAnalysisForPeriod: period over: aDateWeekMonthOrYear w until: until overA: aDateWeekMonthOrYear. - numberOfOpenMergeRequest := self - numberOfOpenMergeRequestSince: since - until: until - overA: aDateWeekMonthOrYear. + openMergeRequests := self + openMergeRequestsSince: since + until: until + overA: aDateWeekMonthOrYear. - numberOfMergedMergeRequest := self - numberOfMergedMergeRequestSince: since - until: until - overA: aDateWeekMonthOrYear. + mergedMergeRequests := self + mergedMergeRequestsSince: since + until: until + overA: aDateWeekMonthOrYear. closedMergeRequests := self closedMergeRequestSince: since @@ -693,10 +693,9 @@ GitMetric4User >> generateAnalysisForPeriod: period over: aDateWeekMonthOrYear w (numberOfProjectWithCommit at: #average); averageTimeBetweenCommits: (averageTimeBetweenCommits at: #average); - averageNumberOfOpenMergeRequest: - (numberOfOpenMergeRequest at: #average); + averageNumberOfOpenMergeRequest: (openMergeRequests at: #average); averageNumberOfMergedMergeRequest: - (numberOfMergedMergeRequest at: #average); + (mergedMergeRequests at: #average); averageClosedMergeRequests: (closedMergeRequests at: #average) ] @@ -823,7 +822,7 @@ GitMetric4User >> mergeRequestDurationSince: since until: until overA: aDateWeek ] { #category : #'metrics - merge request' } -GitMetric4User >> numberOfMergedMergeRequestSince: since until: until overA: aDateWeekMonthOrYear [ +GitMetric4User >> mergedMergeRequestsSince: since until: until overA: aDateWeekMonthOrYear [ | groupedByDate userMergeRequests dateOver average userMergedMergeRequests | groupedByDate := self @@ -833,7 +832,7 @@ GitMetric4User >> numberOfMergedMergeRequestSince: since until: until overA: aDa userMergeRequests := self loadItsMergeRequestsSince: since until: until. - + userMergedMergeRequests := userMergeRequests select: [ :userMergeRequest | userMergeRequest merged_at isNotNil ]. @@ -859,45 +858,6 @@ GitMetric4User >> numberOfMergedMergeRequestSince: since until: until overA: aDa (#userMergeRequests -> userMergeRequests size) } asDictionary ] -{ #category : #'metrics - merge request' } -GitMetric4User >> numberOfOpenMergeRequestSince: since until: until overA: aDateWeekMonthOrYear [ - - | groupedByDate userMergeRequests dateOver average | - groupedByDate := self - setupGroupedDateFrom: since - to: until - over: aDateWeekMonthOrYear. - - userMergeRequests := self - loadItsMergeRequestsSince: since - until: until. - - userMergeRequests 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 - commits' } GitMetric4User >> numberOfProjectWithCommitSince: since until: until overA: aDateWeekMonthOrYear [ | groupedByDate commits userCommits dateOver projects | @@ -944,6 +904,45 @@ GitMetric4User >> numberOfProjectWithCommitSince: since until: until overA: aDat ] +{ #category : #'metrics - merge request' } +GitMetric4User >> openMergeRequestsSince: since until: until overA: aDateWeekMonthOrYear [ + + | groupedByDate userMergeRequests dateOver average | + groupedByDate := self + setupGroupedDateFrom: since + to: until + over: aDateWeekMonthOrYear. + + userMergeRequests := self + loadItsMergeRequestsSince: since + until: until. + + userMergeRequests 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 : #accessing } GitMetric4User >> user [ ^ user From b3f3b8e2504e764b05be3ef989da88ee06718661 Mon Sep 17 00:00:00 2001 From: Kilian B <60846047+knowbased@users.noreply.github.com> Date: Tue, 20 Aug 2024 14:28:11 +0200 Subject: [PATCH 4/5] refactor: rename merge request metrics variables --- .../AnalysisReport.class.st | 70 +++++++++---------- .../GitMetric4User.class.st | 6 +- .../GitMetricExporter.class.st | 35 +++++----- 3 files changed, 54 insertions(+), 57 deletions(-) diff --git a/src/GitLabHealth-Model-Analysis/AnalysisReport.class.st b/src/GitLabHealth-Model-Analysis/AnalysisReport.class.st index ef91438..166ef28 100644 --- a/src/GitLabHealth-Model-Analysis/AnalysisReport.class.st +++ b/src/GitLabHealth-Model-Analysis/AnalysisReport.class.st @@ -14,9 +14,9 @@ Class { 'delayUntilFirstChurn', 'numberOfProjectWithCommit', 'averageTimeBetweenCommits', - 'averageNumberOfOpenMergeRequest', - 'averageNumberOfMergedMergeRequest', - 'averageClosedMergeRequests' + 'openMergeRequest', + 'mergedMergeRequest', + 'closedMergeRequests' ], #category : #'GitLabHealth-Model-Analysis' } @@ -27,51 +27,27 @@ AnalysisReport class >> isVoyageRoot [ ] { #category : #accessing } -AnalysisReport >> averageClosedMergeRequests [ - - ^ averageClosedMergeRequests -] - -{ #category : #accessing } -AnalysisReport >> averageClosedMergeRequests: anObject [ - - averageClosedMergeRequests := anObject -] - -{ #category : #accessing } -AnalysisReport >> averageNumberOfMergedMergeRequest [ - - ^ averageNumberOfMergedMergeRequest -] - -{ #category : #accessing } -AnalysisReport >> averageNumberOfMergedMergeRequest: anObject [ - - averageNumberOfMergedMergeRequest := anObject -] - -{ #category : #accessing } -AnalysisReport >> averageNumberOfOpenMergeRequest [ +AnalysisReport >> averageTimeBetweenCommits [ - ^ averageNumberOfOpenMergeRequest + ^ averageTimeBetweenCommits ] { #category : #accessing } -AnalysisReport >> averageNumberOfOpenMergeRequest: anObject [ +AnalysisReport >> averageTimeBetweenCommits: anObject [ - averageNumberOfOpenMergeRequest := anObject + averageTimeBetweenCommits := anObject ] { #category : #accessing } -AnalysisReport >> averageTimeBetweenCommits [ +AnalysisReport >> closedMergeRequests [ - ^ averageTimeBetweenCommits + ^ closedMergeRequests ] { #category : #accessing } -AnalysisReport >> averageTimeBetweenCommits: anObject [ +AnalysisReport >> closedMergeRequests: anObject [ - averageTimeBetweenCommits := anObject + closedMergeRequests := anObject ] { #category : #accessing } @@ -158,6 +134,18 @@ AnalysisReport >> mergeRequestDuration: anObject [ mergeRequestDuration := anObject ] +{ #category : #accessing } +AnalysisReport >> mergedMergeRequest [ + + ^ mergedMergeRequest +] + +{ #category : #accessing } +AnalysisReport >> mergedMergeRequest: anObject [ + + mergedMergeRequest := anObject +] + { #category : #accessing } AnalysisReport >> numberOfProjectWithCommit [ @@ -170,6 +158,18 @@ AnalysisReport >> numberOfProjectWithCommit: anObject [ numberOfProjectWithCommit := anObject ] +{ #category : #accessing } +AnalysisReport >> openMergeRequest [ + + ^ openMergeRequest +] + +{ #category : #accessing } +AnalysisReport >> openMergeRequest: anObject [ + + openMergeRequest := anObject +] + { #category : #accessing } AnalysisReport >> over [ diff --git a/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st b/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st index adbff4b..321f3ba 100644 --- a/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st +++ b/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st @@ -693,10 +693,10 @@ GitMetric4User >> generateAnalysisForPeriod: period over: aDateWeekMonthOrYear w (numberOfProjectWithCommit at: #average); averageTimeBetweenCommits: (averageTimeBetweenCommits at: #average); - averageNumberOfOpenMergeRequest: (openMergeRequests at: #average); - averageNumberOfMergedMergeRequest: + openMergeRequest: (openMergeRequests at: #average); + mergedMergeRequest: (mergedMergeRequests at: #average); - averageClosedMergeRequests: (closedMergeRequests at: #average) + closedMergeRequests: (closedMergeRequests at: #average) ] { #category : #initialization } diff --git a/src/GitLabHealth-Model-Analysis/GitMetricExporter.class.st b/src/GitLabHealth-Model-Analysis/GitMetricExporter.class.st index c607633..1edced7 100644 --- a/src/GitLabHealth-Model-Analysis/GitMetricExporter.class.st +++ b/src/GitLabHealth-Model-Analysis/GitMetricExporter.class.st @@ -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 ] @@ -207,30 +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. + addColumnForQuery: [ :analysis | analysis openMergeRequest ] + withName: 'number of open merge request' asSymbol. - "average number of merged merge request" + "number of merged merge request" exportBrowserModel - addColumnForQuery: [ :analysis | - analysis averageNumberOfMergedMergeRequest ] - withName: 'average number of merged merge request' asSymbol. - - "Average number of merge requests closed and not merged" + addColumnForQuery: [ :analysis | analysis mergedMergeRequest ] + withName: 'number of merged merge request' asSymbol. + + "number of merge requests closed and not merged" exportBrowserModel - addColumnForQuery: [ :analysis | - analysis averageClosedMergeRequests ] - withName: 'average number of merge requests closed and not merged' asSymbol. - + addColumnForQuery: [ :analysis | analysis closedMergeRequests ] + withName: 'number of merge requests closed and not merged' asSymbol. + file := self constructFilePath: over. file writeStreamDo: [ :aStream | From d70624c8c3f1159057c3f63b8e8340863ea76b51 Mon Sep 17 00:00:00 2001 From: Kilian B <60846047+knowbased@users.noreply.github.com> Date: Tue, 20 Aug 2024 14:59:07 +0200 Subject: [PATCH 5/5] refactor: put back numberOf prefix in merge request metrics method name --- .../AnalysisReport.class.st | 54 ++--- .../GitMetric4User.class.st | 197 +++++++++--------- .../GitMetricExporter.class.st | 6 +- 3 files changed, 129 insertions(+), 128 deletions(-) diff --git a/src/GitLabHealth-Model-Analysis/AnalysisReport.class.st b/src/GitLabHealth-Model-Analysis/AnalysisReport.class.st index 166ef28..8f6a2f6 100644 --- a/src/GitLabHealth-Model-Analysis/AnalysisReport.class.st +++ b/src/GitLabHealth-Model-Analysis/AnalysisReport.class.st @@ -14,9 +14,9 @@ Class { 'delayUntilFirstChurn', 'numberOfProjectWithCommit', 'averageTimeBetweenCommits', - 'openMergeRequest', - 'mergedMergeRequest', - 'closedMergeRequests' + 'numberOfOpenMergeRequests', + 'numberOfMergedMergeRequest', + 'numberOfClosedMergeRequests' ], #category : #'GitLabHealth-Model-Analysis' } @@ -38,18 +38,6 @@ AnalysisReport >> averageTimeBetweenCommits: anObject [ averageTimeBetweenCommits := anObject ] -{ #category : #accessing } -AnalysisReport >> closedMergeRequests [ - - ^ closedMergeRequests -] - -{ #category : #accessing } -AnalysisReport >> closedMergeRequests: anObject [ - - closedMergeRequests := anObject -] - { #category : #accessing } AnalysisReport >> codeAddition [ @@ -135,39 +123,51 @@ AnalysisReport >> mergeRequestDuration: anObject [ ] { #category : #accessing } -AnalysisReport >> mergedMergeRequest [ +AnalysisReport >> numberOfClosedMergeRequests [ - ^ mergedMergeRequest + ^ numberOfClosedMergeRequests ] { #category : #accessing } -AnalysisReport >> mergedMergeRequest: anObject [ +AnalysisReport >> numberOfClosedMergeRequests: anObject [ - mergedMergeRequest := anObject + numberOfClosedMergeRequests := anObject ] { #category : #accessing } -AnalysisReport >> numberOfProjectWithCommit [ +AnalysisReport >> numberOfMergedMergeRequest [ - ^ numberOfProjectWithCommit + ^ numberOfMergedMergeRequest ] { #category : #accessing } -AnalysisReport >> numberOfProjectWithCommit: anObject [ +AnalysisReport >> numberOfMergedMergeRequest: anObject [ - numberOfProjectWithCommit := anObject + numberOfMergedMergeRequest := anObject ] { #category : #accessing } -AnalysisReport >> openMergeRequest [ +AnalysisReport >> numberOfOpenMergeRequests [ - ^ openMergeRequest + ^ numberOfOpenMergeRequests ] { #category : #accessing } -AnalysisReport >> openMergeRequest: anObject [ +AnalysisReport >> numberOfOpenMergeRequests: anObject [ - openMergeRequest := anObject + numberOfOpenMergeRequests := anObject +] + +{ #category : #accessing } +AnalysisReport >> numberOfProjectWithCommit [ + + ^ numberOfProjectWithCommit +] + +{ #category : #accessing } +AnalysisReport >> numberOfProjectWithCommit: anObject [ + + numberOfProjectWithCommit := anObject ] { #category : #accessing } diff --git a/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st b/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st index 321f3ba..cb20def 100644 --- a/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st +++ b/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st @@ -69,50 +69,6 @@ GitMetric4User >> averageTimeBetweenCommitSince: since until: until overA: aDate (#userCommits -> commits size) } asDictionary ] -{ #category : #'metrics - merge request' } -GitMetric4User >> closedMergeRequestSince: 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 : #churn } GitMetric4User >> codeChurnSince: since until: until onACommitWindowOf: commitLimit overA: aDateWeekMonthOrYear [ @@ -615,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 closedMergeRequests openMergeRequests mergedMergeRequests | + | contribution commitFrequency commentContribution mergeRequestDuration codeChurn delayUntilFirstChurn averageTimeBetweenCommits numberOfProjectWithCommit until since numberOfOpenMergeRequests numberOfMergedMergeRequests numberOfClosedMergeRequests | since := period at: #since. until := period at: #until. @@ -663,20 +619,22 @@ GitMetric4User >> generateAnalysisForPeriod: period over: aDateWeekMonthOrYear w until: until overA: aDateWeekMonthOrYear. - openMergeRequests := self - openMergeRequestsSince: since - until: until - overA: aDateWeekMonthOrYear. + numberOfOpenMergeRequests := self + numberOfOpenMergeRequestsSince: since + until: until + overA: aDateWeekMonthOrYear. - mergedMergeRequests := self - mergedMergeRequestsSince: since - until: until - overA: aDateWeekMonthOrYear. + numberOfMergedMergeRequests := self + numberOfMergedMergeRequestsSince: + since + until: until + overA: aDateWeekMonthOrYear. - closedMergeRequests := self - closedMergeRequestSince: since - until: until - overA: aDateWeekMonthOrYear. + numberOfClosedMergeRequests := self + numberOfClosedMergeRequestSince: + since + until: until + overA: aDateWeekMonthOrYear. ^ AnalysisReport new username: self user name; @@ -693,10 +651,9 @@ GitMetric4User >> generateAnalysisForPeriod: period over: aDateWeekMonthOrYear w (numberOfProjectWithCommit at: #average); averageTimeBetweenCommits: (averageTimeBetweenCommits at: #average); - openMergeRequest: (openMergeRequests at: #average); - mergedMergeRequest: - (mergedMergeRequests at: #average); - closedMergeRequests: (closedMergeRequests at: #average) + numberOfOpenMergeRequests: (numberOfOpenMergeRequests at: #average); + numberOfMergedMergeRequest: (numberOfMergedMergeRequests at: #average); + numberOfClosedMergeRequests: (numberOfClosedMergeRequests at: #average) ] { #category : #initialization } @@ -822,33 +779,40 @@ GitMetric4User >> mergeRequestDurationSince: since until: until overA: aDateWeek ] { #category : #'metrics - merge request' } -GitMetric4User >> mergedMergeRequestsSince: since until: until overA: aDateWeekMonthOrYear [ +GitMetric4User >> numberOfClosedMergeRequestSince: since until: until overA: aDateWeekMonthOrYear [ - | groupedByDate userMergeRequests dateOver average userMergedMergeRequests | + | groupedByDate userMergeRequests dateOver average userClosedMergeRequests | groupedByDate := self setupGroupedDateFrom: since to: until over: aDateWeekMonthOrYear. + userMergeRequests := self loadItsMergeRequestsSince: since until: until. - userMergedMergeRequests := userMergeRequests select: [ + userClosedMergeRequests := userMergeRequests select: [ :userMergeRequest | - userMergeRequest merged_at isNotNil ]. + userMergeRequest merged_at isNil and: + userMergeRequest state = 'closed' ]. - userMergedMergeRequests do: [ :userMergeRequest | + 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 @@ -858,54 +822,45 @@ GitMetric4User >> mergedMergeRequestsSince: since until: until overA: aDateWeekM (#userMergeRequests -> userMergeRequests size) } asDictionary ] -{ #category : #'metrics - commits' } -GitMetric4User >> numberOfProjectWithCommitSince: since until: until overA: aDateWeekMonthOrYear [ - | groupedByDate commits userCommits dateOver projects | +{ #category : #'metrics - merge request' } +GitMetric4User >> numberOfMergedMergeRequestsSince: since until: until overA: aDateWeekMonthOrYear [ + + | groupedByDate userMergeRequests dateOver average userMergedMergeRequests | groupedByDate := self setupGroupedDateFrom: since to: until over: aDateWeekMonthOrYear. - - gitAnalyzer := GitAnalyzer new - onModel: glhModel; - glhImporter: glhImporter. + userMergeRequests := self + loadItsMergeRequestsSince: since + until: until. - glhImporter withCommitDiffs: false. - commits := self - loadCommitsFromProjectsIds: itsProjects keys - since: since - until: until. - glhImporter withCommitDiffs: true. - userCommits := commits reject: [ :commit | commit commitCreator ~= user ]. - + userMergedMergeRequests := userMergeRequests select: [ + :userMergeRequest | + userMergeRequest merged_at isNotNil ]. - userCommits do: [ :userCommit | - dateOver := self - transformDate: userCommit committed_date + userMergedMergeRequests do: [ :userMergeRequest | + dateOver := self + transformDate: userMergeRequest created_at to: aDateWeekMonthOrYear. - - groupedByDate at: dateOver printString ifPresent: [ :value | value add: (userCommit repository project) ]. - ]. - - groupedByDate := groupedByDate collect: [ :group | - projects := Set newFrom: group. - projects size. - ]. + 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 - -> - groupedByDate average asFloat). + (#average -> average asFloat). (#details -> groupedByDate). - (#userCommits -> commits size) } asDictionary - + (#userMergeRequests -> userMergeRequests size) } asDictionary ] { #category : #'metrics - merge request' } -GitMetric4User >> openMergeRequestsSince: since until: until overA: aDateWeekMonthOrYear [ +GitMetric4User >> numberOfOpenMergeRequestsSince: since until: until overA: aDateWeekMonthOrYear [ | groupedByDate userMergeRequests dateOver average | groupedByDate := self @@ -943,6 +898,52 @@ GitMetric4User >> openMergeRequestsSince: since until: until overA: aDateWeekMon (#userMergeRequests -> userMergeRequests size) } asDictionary ] +{ #category : #'metrics - commits' } +GitMetric4User >> numberOfProjectWithCommitSince: since until: until overA: aDateWeekMonthOrYear [ + | groupedByDate commits userCommits dateOver projects | + groupedByDate := self + setupGroupedDateFrom: since + to: until + over: aDateWeekMonthOrYear. + + gitAnalyzer := GitAnalyzer new + onModel: glhModel; + glhImporter: glhImporter. + + glhImporter withCommitDiffs: false. + commits := self + loadCommitsFromProjectsIds: itsProjects keys + since: since + until: until. + glhImporter withCommitDiffs: true. + userCommits := commits reject: [ :commit | commit commitCreator ~= user ]. + + + userCommits do: [ :userCommit | + dateOver := self + transformDate: userCommit committed_date + to: aDateWeekMonthOrYear. + + groupedByDate at: dateOver printString ifPresent: [ :value | value add: (userCommit repository project) ]. + ]. + + groupedByDate := groupedByDate collect: [ :group | + projects := Set newFrom: group. + projects size. + ]. + + ^ { + (#overEach -> aDateWeekMonthOrYear name). + (#forOver -> (groupedByDate keys size printString + , aDateWeekMonthOrYear printString)). + (#average + -> + groupedByDate average asFloat). + (#details -> groupedByDate). + (#userCommits -> commits size) } asDictionary + +] + { #category : #accessing } GitMetric4User >> user [ ^ user diff --git a/src/GitLabHealth-Model-Analysis/GitMetricExporter.class.st b/src/GitLabHealth-Model-Analysis/GitMetricExporter.class.st index 1edced7..af7b0ec 100644 --- a/src/GitLabHealth-Model-Analysis/GitMetricExporter.class.st +++ b/src/GitLabHealth-Model-Analysis/GitMetricExporter.class.st @@ -214,18 +214,18 @@ GitMetricExporter >> exportInCSV [ "number of open merge request" exportBrowserModel - addColumnForQuery: [ :analysis | analysis openMergeRequest ] + addColumnForQuery: [ :analysis | analysis numberOfOpenMergeRequests ] withName: 'number of open merge request' asSymbol. "number of merged merge request" exportBrowserModel - addColumnForQuery: [ :analysis | analysis mergedMergeRequest ] + addColumnForQuery: [ :analysis | analysis numberOfMergedMergeRequest ] withName: 'number of merged merge request' asSymbol. "number of merge requests closed and not merged" exportBrowserModel - addColumnForQuery: [ :analysis | analysis closedMergeRequests ] + addColumnForQuery: [ :analysis | analysis numberOfClosedMergeRequests ] withName: 'number of merge requests closed and not merged' asSymbol.