From 67e04fe6c8c95f714b63c973315ac65bb19fb0b3 Mon Sep 17 00:00:00 2001 From: Kilian B <60846047+knowbased@users.noreply.github.com> Date: Fri, 23 Aug 2024 15:56:07 +0200 Subject: [PATCH 1/4] feat: add load its merge request with jira issue method --- .../GitMetric.class.st | 7 +++++ .../GitMetric4User.class.st | 19 ++++++++++++ .../GitMetricExporter.class.st | 31 +++++++++++++------ 3 files changed, 47 insertions(+), 10 deletions(-) diff --git a/src/GitLabHealth-Model-Analysis/GitMetric.class.st b/src/GitLabHealth-Model-Analysis/GitMetric.class.st index ac30ac5..5127304 100644 --- a/src/GitLabHealth-Model-Analysis/GitMetric.class.st +++ b/src/GitLabHealth-Model-Analysis/GitMetric.class.st @@ -4,6 +4,7 @@ Class { #instVars : [ 'user', 'glhImporter', + 'jiraImporter', 'itsProjects', 'gitAnalyzer', 'glhModel' @@ -85,6 +86,12 @@ GitMetric >> glhImporter: aGLPHModelImporter [ glhImporter := aGLPHModelImporter ] +{ #category : #accessing } +GitMetric >> jiraImporter: anObject [ + + jiraImporter := anObject +] + { #category : #churn } GitMetric >> loadCommitsFromProjectsIds: aCollection since: since until: until [ diff --git a/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st b/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st index de01d63..3aed82b 100644 --- a/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st +++ b/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st @@ -697,6 +697,25 @@ GitMetric4User >> loadCommitOfProjects: aCollection since: aTimespan [ ^ self userCommits. ] +{ #category : #loading } +GitMetric4User >> loadItsMergeRequesWithJiraIssueSince: since until: until [ + + itsMergeRequests := self + loadItsMergeRequestsSince: since + until: until. + + jiraImporter importAllCurrentAndPastIssuesOf: + user commits anyOne author_email. + + GPJCConnector new + gpModel: glhImporter glhModel; + jiraModel: jiraImporter model; + connect. + + ^ itsMergeRequests select: [ :mergeRequest | + mergeRequest jiraIssue isNotNil ] +] + { #category : #loading } GitMetric4User >> loadItsMergeRequestsSince: since until: until [ diff --git a/src/GitLabHealth-Model-Analysis/GitMetricExporter.class.st b/src/GitLabHealth-Model-Analysis/GitMetricExporter.class.st index f5acb21..4e2f50a 100644 --- a/src/GitLabHealth-Model-Analysis/GitMetricExporter.class.st +++ b/src/GitLabHealth-Model-Analysis/GitMetricExporter.class.st @@ -3,6 +3,7 @@ Class { #superclass : #Object, #instVars : [ 'glhImporter', + 'jiraImporter', 'label', 'entities', 'projectCache', @@ -45,11 +46,14 @@ GitMetricExporter >> addEntitiesFromUserNames: userNames [ "then collect the project in which the user has be seen commited" entities addAll: (userNames collect: [ :username | | projects metrics i size | - projects := self findParticipationOfCommitAuthorNamed: username amongProjects: projectCache. + projects := self + findParticipationOfCommitAuthorNamed: username + amongProjects: projectCache. metrics := GitMetric4User new. metrics glhImporter: glhImporter; + jiraImporter: jiraImporter; findUserNamed: username. @@ -77,17 +81,18 @@ GitMetricExporter >> addEntitiesFromUserNames: userNames [ GitMetricExporter >> addEntitiesFromUserNamesAndProjects: usersWithProjects [ entities addAll: (usersWithProjects associations collect: [ :assoc | - | username projects metrics | - username := assoc key. - projects := assoc value. + | username projects metrics | + username := assoc key. + projects := assoc value. - metrics := GitMetric4User new. - metrics - glhImporter: glhImporter; - findUserNamed: username. - metrics loadProjectsFromIds: projects. + metrics := GitMetric4User new. + metrics + glhImporter: glhImporter; + jiraImporter: jiraImporter; + findUserNamed: username. + metrics loadProjectsFromIds: projects. - metrics ]). + metrics ]). ^ self ] @@ -418,6 +423,12 @@ GitMetricExporter >> initialize [ over := Date ] +{ #category : #accessing } +GitMetricExporter >> jiraImporter: anObject [ + + jiraImporter := anObject +] + { #category : #accessing } GitMetricExporter >> label: aString [ label := aString From 2e8a04ef8a7687aaf923936df9f71e4f8605ddd9 Mon Sep 17 00:00:00 2001 From: Kilian B <60846047+knowbased@users.noreply.github.com> Date: Fri, 23 Aug 2024 16:39:36 +0200 Subject: [PATCH 2/4] feat: number of jira tickets closed metric --- .../GitMetric4User.class.st | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st b/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st index 3aed82b..3f7068a 100644 --- a/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st +++ b/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st @@ -1033,6 +1033,47 @@ GitMetric4User >> numberOfProjectWithCommitSince: since until: until overA: aDat ] +{ #category : #'metrics -jira' } +GitMetric4User >> numberOfTicketsClosedSince: since until: until overA: aDateWeekMonthOrYear [ + + | groupedByDate itsMergeRequestsWithJiraIssue dateOver average mergedMergeRequestWithJiraIssue | + groupedByDate := self + setupGroupedDateFrom: since + to: until + over: aDateWeekMonthOrYear. + + itsMergeRequestsWithJiraIssue := self + loadItsMergeRequesWithJiraIssueSince: + since + until: until. + + mergedMergeRequestWithJiraIssue := itsMergeRequestsWithJiraIssue + select: [ :mr | + mr merged_at isNotNil ]. + + mergedMergeRequestWithJiraIssue 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). + (#userMergeRequestsWithJiraIssue -> itsMergeRequestsWithJiraIssue size) } + asDictionary +] + { #category : #accessing } GitMetric4User >> user [ ^ user From e497baaaa898b4440659ecd3914f6e8830fb5602 Mon Sep 17 00:00:00 2001 From: Kilian B <60846047+knowbased@users.noreply.github.com> Date: Fri, 23 Aug 2024 16:46:29 +0200 Subject: [PATCH 3/4] feat: add numberOfTicketClosed in analysisReport and csv export --- .../AnalysisReport.class.st | 15 ++++- .../GitMetricExporter.class.st | 62 +++++++++++++------ 2 files changed, 56 insertions(+), 21 deletions(-) diff --git a/src/GitLabHealth-Model-Analysis/AnalysisReport.class.st b/src/GitLabHealth-Model-Analysis/AnalysisReport.class.st index cf7b3fc..2da1f3d 100644 --- a/src/GitLabHealth-Model-Analysis/AnalysisReport.class.st +++ b/src/GitLabHealth-Model-Analysis/AnalysisReport.class.st @@ -17,7 +17,8 @@ Class { 'numberOfOpenMergeRequests', 'numberOfMergedMergeRequest', 'numberOfClosedMergeRequests', - 'numberOfMergeRequestsWithoutReview' + 'numberOfMergeRequestsWithoutReview', + 'numberOfTicketsClosed' ], #category : #'GitLabHealth-Model-Analysis' } @@ -183,6 +184,18 @@ AnalysisReport >> numberOfProjectWithCommit: anObject [ numberOfProjectWithCommit := anObject ] +{ #category : #accessing } +AnalysisReport >> numberOfTicketsClosed [ + + ^ numberOfTicketsClosed +] + +{ #category : #accessing } +AnalysisReport >> numberOfTicketsClosed: anObject [ + + numberOfTicketsClosed := anObject +] + { #category : #accessing } AnalysisReport >> over [ diff --git a/src/GitLabHealth-Model-Analysis/GitMetricExporter.class.st b/src/GitLabHealth-Model-Analysis/GitMetricExporter.class.st index 4e2f50a..6d55fcd 100644 --- a/src/GitLabHealth-Model-Analysis/GitMetricExporter.class.st +++ b/src/GitLabHealth-Model-Analysis/GitMetricExporter.class.st @@ -138,15 +138,17 @@ GitMetricExporter >> csvMetricsFor: date [ ('commits frequency (avg) - ' , date asString -> [ :groupAnalyses | - | analysis | - analysis := self getAnalysisWithDate: date from: groupAnalyses. - analysis ifNil: [ nil ] ifNotNil: [ analysis commitFrequency ] ]). + | analysis | + analysis := self getAnalysisWithDate: date from: groupAnalyses. + analysis ifNil: [ nil ] ifNotNil: [ analysis commitFrequency ] ]). ('comment contribution (avg) - ' , date asString -> [ :groupAnalyses | - | analysis | - analysis := self getAnalysisWithDate: date from: groupAnalyses. - analysis ifNil: [ nil ] ifNotNil: [ analysis commentContribution ] ]). + | analysis | + analysis := self getAnalysisWithDate: date from: groupAnalyses. + analysis + ifNil: [ nil ] + ifNotNil: [ analysis commentContribution ] ]). ('churn % (W=' , maxCommitWindow printString , ') - ' , date asString -> [ :groupAnalyses | @@ -158,7 +160,9 @@ GitMetricExporter >> csvMetricsFor: date [ , ') - ' , date asString -> [ :groupAnalyses | | analysis | analysis := self getAnalysisWithDate: date from: groupAnalyses. - analysis ifNil: [ nil ] ifNotNil: [ analysis delayUntilFirstChurn ] ]). + analysis + ifNil: [ nil ] + ifNotNil: [ analysis delayUntilFirstChurn ] ]). ('number of project with min 1 commit of user - ' , date asString -> [ :groupAnalyses | @@ -168,9 +172,11 @@ GitMetricExporter >> csvMetricsFor: date [ ('merge Request Duration - ' , date asString -> [ :groupAnalyses | - | analysis | - analysis := self getAnalysisWithDate: date from: groupAnalyses. - analysis ifNil: [ nil ] ifNotNil: [ analysis mergeRequestDuration ] ]). + | analysis | + analysis := self getAnalysisWithDate: date from: groupAnalyses. + analysis + ifNil: [ nil ] + ifNotNil: [ analysis mergeRequestDuration ] ]). ('average time between commits - ' , date asString -> [ :groupAnalyses | @@ -180,27 +186,43 @@ GitMetricExporter >> csvMetricsFor: date [ ('number of open merge request - ' , date asString -> [ :groupAnalyses | - | analysis | - analysis := self getAnalysisWithDate: date from: groupAnalyses. - analysis ifNil: [ nil ] ifNotNil: [ analysis numberOfOpenMergeRequests ] ]). + | analysis | + analysis := self getAnalysisWithDate: date from: groupAnalyses. + analysis + ifNil: [ nil ] + ifNotNil: [ analysis numberOfOpenMergeRequests ] ]). ('number of merged merge request - ' , date asString -> [ :groupAnalyses | - | analysis | - analysis := self getAnalysisWithDate: date from: groupAnalyses. - analysis ifNil: [ nil ] ifNotNil: [ analysis numberOfMergedMergeRequest ] ]). + | analysis | + analysis := self getAnalysisWithDate: date from: groupAnalyses. + analysis + ifNil: [ nil ] + ifNotNil: [ analysis numberOfMergedMergeRequest ] ]). ('number of merge requests closed and not merged - ' , date asString -> [ :groupAnalyses | | analysis | analysis := self getAnalysisWithDate: date from: groupAnalyses. - analysis ifNil: [ nil ] ifNotNil: [ analysis numberOfClosedMergeRequests ] ]). + analysis + ifNil: [ nil ] + ifNotNil: [ analysis numberOfClosedMergeRequests ] ]). ('number of merge requests without review - ' , date asString -> [ :groupAnalyses | - | analysis | - analysis := self getAnalysisWithDate: date from: groupAnalyses. - analysis ifNil: [ nil ] ifNotNil: [ analysis numberOfMergeRequestsWithoutReview ] ]) } + | analysis | + analysis := self getAnalysisWithDate: date from: groupAnalyses. + analysis + ifNil: [ nil ] + ifNotNil: [ analysis numberOfMergeRequestsWithoutReview ] ]). + + ('number of merge request with jira ticket closed - ' , date asString + -> [ :groupAnalyses | + | analysis | + analysis := self getAnalysisWithDate: date from: groupAnalyses. + analysis + ifNil: [ nil ] + ifNotNil: [ analysis numberOfTicketsClosed ] ]) } ] { #category : #accessing } From 77f7293efec7993a83defa7554584934ff6b06ff Mon Sep 17 00:00:00 2001 From: Kilian B <60846047+knowbased@users.noreply.github.com> Date: Fri, 23 Aug 2024 16:47:11 +0200 Subject: [PATCH 4/4] feat: add number of tickets closed in generateAnalysis --- .../GitMetric4User.class.st | 25 ++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st b/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st index 3f7068a..f2e21d7 100644 --- a/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st +++ b/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st @@ -571,38 +571,31 @@ 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 numberOfMergeRequestWithoutReview | + | contribution commitFrequency commentContribution mergeRequestDuration codeChurn delayUntilFirstChurn averageTimeBetweenCommits numberOfProjectWithCommit until since numberOfOpenMergeRequests numberOfMergedMergeRequests numberOfClosedMergeRequests numberOfMergeRequestWithoutReview numberOfTicketsClosed | since := period at: #since. until := period at: #until. - - "COMMITS" contribution := self codeContributionsSince: since until: until overA: aDateWeekMonthOrYear. - commitFrequency := self commitFrequencySince: since until: until overA: aDateWeekMonthOrYear. - commentContribution := self commentsContributionsSince: since until: until overA: aDateWeekMonthOrYear. - codeChurn := self codeChurnSince: since until: until onACommitWindowOf: maxCommitWindow overA: aDateWeekMonthOrYear. - delayUntilFirstChurn := self delayUntilFirstChurnSince: since until: until onACommitWindowOf: maxCommitWindow overA: aDateWeekMonthOrYear. - numberOfProjectWithCommit := self numberOfProjectWithCommitSince: since until: until @@ -611,37 +604,33 @@ GitMetric4User >> generateAnalysisForPeriod: period over: aDateWeekMonthOrYear w averageTimeBetweenCommitSince: since until: until overA: aDateWeekMonthOrYear. - - "MERGE REQUESTS" - mergeRequestDuration := self mergeRequestDurationSince: since until: until overA: aDateWeekMonthOrYear. - numberOfOpenMergeRequests := self numberOfOpenMergeRequestsSince: since until: until overA: aDateWeekMonthOrYear. - numberOfMergedMergeRequests := self numberOfMergedMergeRequestsSince: since until: until overA: aDateWeekMonthOrYear. - numberOfClosedMergeRequests := self numberOfClosedMergeRequestSince: since until: until overA: aDateWeekMonthOrYear. - numberOfMergeRequestWithoutReview := self numberOfMergeRequestsMergedWithoutReviewSince: since until: until overA: aDateWeekMonthOrYear. - + numberOfTicketsClosed := self + numberOfTicketsClosedSince: since + until: until + overA: aDateWeekMonthOrYear. ^ AnalysisReport new username: self user name; period: period; @@ -663,7 +652,9 @@ GitMetric4User >> generateAnalysisForPeriod: period over: aDateWeekMonthOrYear w (numberOfMergedMergeRequests at: #average); numberOfClosedMergeRequests: (numberOfClosedMergeRequests at: #average); - numberOfMergeRequestsWithoutReview: (numberOfMergeRequestWithoutReview at: #average). + numberOfMergeRequestsWithoutReview: + (numberOfMergeRequestWithoutReview at: #average); + numberOfTicketsClosed: (numberOfTicketsClosed at: #average) ] { #category : #initialization }