diff --git a/src/GitLabHealth-Model-Analysis/CodeChurnMetric.class.st b/src/GitLabHealth-Model-Analysis/CodeChurnMetric.class.st index 5e41133..18917e8 100644 --- a/src/GitLabHealth-Model-Analysis/CodeChurnMetric.class.st +++ b/src/GitLabHealth-Model-Analysis/CodeChurnMetric.class.st @@ -12,12 +12,12 @@ CodeChurnMetric >> calculate [ | commits res groupedByDate totalContributions gitAnalyzer | userCommits ifNil: [ self load ]. - + totalContributions := OrderedCollection new. groupedByDate := self setupGroupedDate. gitAnalyzer := GitAnalyzer new maxChildCommit: maxCommitWindow. - commits := user + commits := self foundSuccessorOf: userCommits andCompleteImportForMax: maxCommitWindow. diff --git a/src/GitLabHealth-Model-Analysis/CommentContributionMetric.class.st b/src/GitLabHealth-Model-Analysis/CommentContributionMetric.class.st index b37793a..33d3fe4 100644 --- a/src/GitLabHealth-Model-Analysis/CommentContributionMetric.class.st +++ b/src/GitLabHealth-Model-Analysis/CommentContributionMetric.class.st @@ -47,7 +47,10 @@ CommentContributionMetric >> description [ { #category : #loading } CommentContributionMetric >> load [ - userCommits := user loadCompleteCommitsSince: (period at: #since) until: (period at: #until). + + userCommits := self + loadCompleteCommitsSince: (period at: #since) + until: (period at: #until) ] { #category : #accessing } diff --git a/src/GitLabHealth-Model-Analysis/DelayUntilFirstChurnMetric.class.st b/src/GitLabHealth-Model-Analysis/DelayUntilFirstChurnMetric.class.st index 4bc759c..61b51fa 100644 --- a/src/GitLabHealth-Model-Analysis/DelayUntilFirstChurnMetric.class.st +++ b/src/GitLabHealth-Model-Analysis/DelayUntilFirstChurnMetric.class.st @@ -13,14 +13,14 @@ DelayUntilFirstChurnMetric >> calculate [ | commits groupedByDate res average | userCommits ifNil: [ self load ]. groupedByDate := self setupGroupedDate. - commits := user + commits := self foundSuccessorOf: userCommits andCompleteImportForMax: maxCommitWindow. "class commit by dates, filter none user commits" commits do: [ :commit | - commit commitCreator = user user ifTrue: [ + commit commitCreator = user ifTrue: [ | overDate | overDate := self transformDate: commit created_at to: over. @@ -59,7 +59,7 @@ DelayUntilFirstChurnMetric >> calculate [ ifFalse: [ (filtered sum: [ :v | v asDuration asSeconds ]) / filtered size ] ]. - + res := res reject: #isNil. average := res diff --git a/src/GitLabHealth-Model-Analysis/GitMetric.class.st b/src/GitLabHealth-Model-Analysis/GitMetric.class.st deleted file mode 100644 index 5127304..0000000 --- a/src/GitLabHealth-Model-Analysis/GitMetric.class.st +++ /dev/null @@ -1,213 +0,0 @@ -Class { - #name : #GitMetric, - #superclass : #Object, - #instVars : [ - 'user', - 'glhImporter', - 'jiraImporter', - 'itsProjects', - 'gitAnalyzer', - 'glhModel' - ], - #category : #'GitLabHealth-Model-Analysis' -} - -{ #category : #setup } -GitMetric class >> setupGroupedDateFrom: since to: until over: aDateWeekMonthOrYear [ - - | groupedByDate start end over increment | - groupedByDate := OrderedDictionary new. - - increment := 1. - start := self transformDate: since to: aDateWeekMonthOrYear. - end := self transformDate: until to: aDateWeekMonthOrYear. - - groupedByDate - at: start printString - ifAbsentPut: [ OrderedCollection new ]. - - over := aDateWeekMonthOrYear name asLowercase asSymbol. - over = #date ifTrue: [ over := #day ]. - over = #month ifTrue: [ - increment := 32. - over := #day ]. - - - [ groupedByDate keys last asDateAndTime < end ] whileTrue: [ - | index | - index := groupedByDate keys last asDateAndTime - + (increment perform: over). - index := self transformDate: index to: aDateWeekMonthOrYear. - groupedByDate - at: index printString - ifAbsentPut: [ OrderedCollection new ] ]. - - - over = #day ifTrue: [ - groupedByDate keysDo: [ :date | - | aWeekday | - aWeekday := date asDate weekday. - (aWeekday = #Sunday or: [ aWeekday = #Saturday ]) ifTrue: [ - groupedByDate removeKey: date ] ] ]. - - - groupedByDate - at: end printString - ifAbsentPut: [ OrderedCollection new ]. - - ^ groupedByDate -] - -{ #category : #'as yet unclassified' } -GitMetric class >> transformDate: date to: aWeekOrMonthOrYear [ - - aWeekOrMonthOrYear = Month ifTrue: [ ^ date asDate month asDate ]. - - ^ (date asDate perform: ('as' , aWeekOrMonthOrYear name) asSymbol) - asDate -] - -{ #category : #'as yet unclassified' } -GitMetric >> cacheSymbolFor: anEntityType since: since until: until [ - - ^ (anEntityType printString , ' since ' , since printString , ' to ' - , until printString) asSymbol -] - -{ #category : #'as yet unclassified' } -GitMetric >> findUserNamed: aUsername [ - - user := glhImporter importUserByUsername: aUsername. - ^ user -] - -{ #category : #accessing } -GitMetric >> glhImporter: aGLPHModelImporter [ - glhImporter := aGLPHModelImporter -] - -{ #category : #accessing } -GitMetric >> jiraImporter: anObject [ - - jiraImporter := anObject -] - -{ #category : #churn } -GitMetric >> loadCommitsFromProjectsIds: aCollection since: since until: until [ - - | allCommits period size i| - period := self cacheSymbolFor: GLHCommit since: since until: until. - - "download commits unless project cache is not empty" - allCommits := aCollection collect: [ :idProject | - | project | - project := itsProjects at: idProject. - project repository cacheAt: period ifAbsentPut: [ - | foundCommits | - foundCommits := glhImporter - importCommitsOProject: project - since: since - until: until. - foundCommits ] ]. - - allCommits := allCommits flatten. - - i := 0. - size := allCommits size. - allCommits do: [ :commit | - ('import commit creators [', (i:=i+1) printString, '/', size printString) recordInfo. - - glhImporter importCreatorOfCommit: commit ]. - - glhImporter chainsCommitsFrom: allCommits. - - ^ allCommits -] - -{ #category : #churn } -GitMetric >> loadMergeRequestsFromProjectsIds: aCollection since: since until: until [ - - | allMr period | - "itsMergeRequests ifNil: [ itsMergeRequests := Dictionary new ]." - period := self - cacheSymbolFor: GLPHEMergeRequest - since: since - until: until. - - allMr := aCollection collect: [ :idProject | - | project mr | - project := itsProjects at: idProject. - project cacheAt: period ifAbsentPut: [ - mr := glhImporter - importMergeRequests: project - since: since - until: until. - mr ] ]. - - ^ allMr flattened -] - -{ #category : #loading } -GitMetric >> loadProjectsFromIds: projectIds [ - - projectIds do: [ :id | - - itsProjects at: id ifAbsentPut: [ glhImporter importProject: id ] ]. - - ^ itsProjects -] - -{ #category : #setup } -GitMetric >> setupGroupedDateFrom: since to: until over: aDateWeekMonthOrYear [ - - | groupedByDate start end over increment | - groupedByDate := OrderedDictionary new. - - increment := 1. - start := self transformDate: since to: aDateWeekMonthOrYear. - end := self transformDate: until to: aDateWeekMonthOrYear. - - groupedByDate - at: start printString - ifAbsentPut: [ OrderedCollection new ]. - - over := aDateWeekMonthOrYear name asLowercase asSymbol. - over = #date ifTrue: [ over := #day ]. - over = #month ifTrue: [ - increment := 32. - over := #day ]. - - - [ groupedByDate keys last asDateAndTime < end ] whileTrue: [ - | index | - index := groupedByDate keys last asDateAndTime - + (increment perform: over). - index := self transformDate: index to: aDateWeekMonthOrYear. - groupedByDate - at: index printString - ifAbsentPut: [ OrderedCollection new ] ]. - - - over = #day ifTrue: [ - - groupedByDate := (groupedByDate associations select: [ :date | - | aWeekday | - aWeekday := date key asDate weekday. - (aWeekday = #Sunday or: [ aWeekday = #Saturday ]) not ]) asOrderedDictionary ]. - - - groupedByDate - at: end printString - ifAbsentPut: [ OrderedCollection new ]. - - ^ groupedByDate -] - -{ #category : #'as yet unclassified' } -GitMetric >> transformDate: date to: aWeekOrMonthOrYear [ - - aWeekOrMonthOrYear = Month ifTrue: [ ^ date asDate month asDate ]. - - ^ (date asDate perform: ('as' , aWeekOrMonthOrYear name) asSymbol) - asDate -] diff --git a/src/GitLabHealth-Model-Analysis/GitMetric4Group.class.st b/src/GitLabHealth-Model-Analysis/GitMetric4Group.class.st deleted file mode 100644 index dc8a9ec..0000000 --- a/src/GitLabHealth-Model-Analysis/GitMetric4Group.class.st +++ /dev/null @@ -1,8 +0,0 @@ -Class { - #name : #GitMetric4Group, - #superclass : #GitMetric, - #instVars : [ - 'project' - ], - #category : 'GitLabHealth-Model-Analysis' -} diff --git a/src/GitLabHealth-Model-Analysis/GitMetric4Project.class.st b/src/GitLabHealth-Model-Analysis/GitMetric4Project.class.st deleted file mode 100644 index 4e7136c..0000000 --- a/src/GitLabHealth-Model-Analysis/GitMetric4Project.class.st +++ /dev/null @@ -1,8 +0,0 @@ -Class { - #name : #GitMetric4Project, - #superclass : #GitMetric, - #instVars : [ - 'project' - ], - #category : 'GitLabHealth-Model-Analysis' -} diff --git a/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st b/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st deleted file mode 100644 index c9bc3cf..0000000 --- a/src/GitLabHealth-Model-Analysis/GitMetric4User.class.st +++ /dev/null @@ -1,211 +0,0 @@ -Class { - #name : #GitMetric4User, - #superclass : #GitMetric, - #instVars : [ - 'itsCommits', - 'itsMergeRequests', - 'emailDomain' - ], - #category : #'GitLabHealth-Model-Analysis' -} - -{ #category : #churn } -GitMetric4User >> foundSuccessorOf: userCommits andCompleteImportForMax: commitLimit [ - - | analyzingCommits i size | - analyzingCommits := Set new. - glhImporter withCommitDiffs: true. - - userCommits do: [ :c | - GitAnalyzer new - visitChildCommits: c childCommits - toStoreThemIn: analyzingCommits - upto: commitLimit ]. - - i := 0. - size := analyzingCommits size. - analyzingCommits do: [ :c | - ('import complete commits [' , (i := i + 1) printString , '/' - , size printString , ']') recordInfo. - glhImporter completeImportedCommit: c ]. - - ^ analyzingCommits -] - -{ #category : #initialization } -GitMetric4User >> initialize [ - - user := GLHUser new. - itsCommits := Dictionary new. - itsMergeRequests := Dictionary new. - - emailDomain := '@generic-domain.com' -] - -{ #category : #accessing } -GitMetric4User >> itsProjects: projects [ - itsProjects := projects . -] - -{ #category : #churn } -GitMetric4User >> loadCommitOfProjects: aCollection since: aTimespan [ - |commits| - - commits := (aCollection collect: [ :id | - glhImporter - importCommitsOProject: (itsProjects at: id) - since: aTimespan - until: nil ]) flattened. - - commits do: [ :commit | - glhImporter completeImportedCommit: commit. - ]. - - ^ self userCommits. -] - -{ #category : #loading } -GitMetric4User >> loadCommitsSince: since until: until [ - - | cacheSymbol allCommits userCommits | - itsProjects ifNil: [ self loadProjects ]. - - glhImporter withCommitDiffs: false. - - cacheSymbol := self - cacheSymbolFor: GLHCommit - since: since - until: until. - - "download commits unless project cache is not empty" - allCommits := itsProjects collect: [ :project | - project repository cacheAt: cacheSymbol ifAbsentPut: [ - | foundCommits | - foundCommits := glhImporter - importCommitsOProject: project - since: since - until: until. - foundCommits ] ]. - - allCommits := allCommits flatten. - allCommits do: [ :commit | glhImporter importCreatorOfCommit: commit ]. - glhImporter chainsCommitsFrom: allCommits. - glhImporter withCommitDiffs: true. - - ^ userCommits := allCommits reject: [ :commit | - commit commitCreator ~= user ] -] - -{ #category : #loading } -GitMetric4User >> loadCompleteCommitsSince: since until: until [ - - | commits | - commits := self loadCommitsSince: since until: until. - commits do: [ :commit | glhImporter completeImportedCommit: commit ]. - ^commits - - -] - -{ #category : #loading } -GitMetric4User >> loadCompleteMergeRequestsSince: since until: until [ - - | mergeRequests | - mergeRequests := self loadMergeRequestsSince: since until: until. - - mergeRequests do: [ :mergeRequest | - glhImporter importMergeResquestMerger: mergeRequest ]. - - ^mergeRequests -] - -{ #category : #loading } -GitMetric4User >> loadMergeRequestsSince: since until: until [ - - | cacheSymbol mergeRequests userMergeRequests | - itsProjects ifNil: [ self loadProjects ]. - glhImporter withCommitDiffs: false. - cacheSymbol := self - cacheSymbolFor: GLPHEMergeRequest - since: since - until: until. - - mergeRequests := itsProjects collect: [ :project | - | mr | - project cacheAt: cacheSymbol ifAbsentPut: [ - mr := glhImporter - importMergeRequests: project - since: since - until: until. - mr ] ]. - - mergeRequests := mergeRequests flattened. - glhImporter withCommitDiffs: true. - - mergeRequests do: [ :mr | glhImporter importMergeResquestAuthor: mr ]. - - userMergeRequests := mergeRequests select: [ :mergeRequest | - mergeRequest author = user ]. - ^ userMergeRequests -] - -{ #category : #loading } -GitMetric4User >> loadMergeRequestsWithJiraIssueSince: since until: until [ - - | email | - itsMergeRequests := self loadMergeRequestsSince: since until: until. - - email := self userEmail. - - jiraImporter importAllCurrentAndPastIssuesOf: email. - - GPJCConnector new - gpModel: glhImporter glhModel; - jiraModel: jiraImporter model; - connect. - - ^ itsMergeRequests select: [ :mergeRequest | - mergeRequest jiraIssue isNotNil ] -] - -{ #category : #loading } -GitMetric4User >> loadProjects [ - - itsProjects ifNotNil: [ ^ itsProjects ]. - - itsProjects := glhImporter importContributedProjectsOfUser: user. - - itsProjects do: [ :project | - glhImporter completeImportProject: project ]. - - ^ itsProjects -] - -{ #category : #accessing } -GitMetric4User >> user [ - ^ user -] - -{ #category : #accessing } -GitMetric4User >> user: anUser [ - user := anUser. -] - -{ #category : #accessing } -GitMetric4User >> userCommits [ - ^ user commits -] - -{ #category : #email } -GitMetric4User >> userEmail [ - "overide this method to adapt on your situation" - - ^ ('' join: { - user username. - emailDomain }) asLowercase. -] - -{ #category : #email } -GitMetric4User >> withUserEmailDomain: aEmailDomain [ - emailDomain := aEmailDomain. -] diff --git a/src/GitLabHealth-Model-Analysis/GitMetricExporter.class.st b/src/GitLabHealth-Model-Analysis/GitMetricExporter.class.st index aac90d5..7d31e12 100644 --- a/src/GitLabHealth-Model-Analysis/GitMetricExporter.class.st +++ b/src/GitLabHealth-Model-Analysis/GitMetricExporter.class.st @@ -40,6 +40,12 @@ GitMetricExporter >> addAPeriodFrom: since to: until [ { #category : #adding } GitMetricExporter >> addEntitiesFromUserNames: userNames [ "import all the project since a certain time" + + self + deprecated: 'Use #setupAnalysesForUsersWithNames instead' + on: '03 Sept 2024' + in: + 'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'. 'Import all projects from the Git repository' recordInfo. projectCache := projectCache ifNil: [ @@ -47,16 +53,16 @@ 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 i size | projects := self findParticipationOfCommitAuthorNamed: username amongProjects: projectCache. - metrics := GitMetric4User new. + "metrics := GitMetric4User new. metrics glhImporter: glhImporter; - jiraImporter: jiraImporter; - findUserNamed: username. + jiraImporter: jiraImporter; + findUserNamed: username." @@ -82,21 +88,27 @@ GitMetricExporter >> addEntitiesFromUserNames: userNames [ { #category : #adding } GitMetricExporter >> addEntitiesFromUserNamesAndProjects: usersWithProjects [ + self + deprecated: 'Use #setupAnalysesForUsersWithNames instead' + on: '03 Sept 2024' + in: + 'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'. + entities addAll: (usersWithProjects associations collect: [ :assoc | - | username projects metrics | + | username projects | username := assoc key. projects := assoc value. - metrics := GitMetric4User new. + " metrics := GitMetric4User new. metrics glhImporter: glhImporter; jiraImporter: jiraImporter; findUserNamed: username. - metrics loadProjectsFromIds: projects. + metrics loadProjectsFromIds: projects." - metrics ]). + username ]). - ^ self + ^ self ] { #category : #accessing } @@ -283,7 +295,7 @@ GitMetricExporter >> generateAnalysesOver: aDateWeekMonthOrYear [ runningPeriods do: [ :period | analysesReport := entities collect: [ :entity | userAnalysisReport := UserAnalysisReport new - username: entity user name; + username: entity name; period: period; over: aDateWeekMonthOrYear. @@ -293,7 +305,10 @@ GitMetricExporter >> generateAnalysesOver: aDateWeekMonthOrYear [ (period at: #since) until: (period at: #until); over: aDateWeekMonthOrYear; - user: entity. + user: entity; + glhImporter: glhImporter; + jiraImporter: jiraImporter; + emailDomain: emailDomain. result := newMetric calculate. @@ -407,18 +422,16 @@ GitMetricExporter >> setupAnalysisForUsersWithNames: userNames [ glhImporter importUserByUsername: username ]. glhImporter userCatalogue scrapeAuthorNamesForUsers: users. - - entities addAll: (users collect: [ :user | - | metricUser | - metricUser := GitMetric4User new. - metricUser - glhImporter: glhImporter; - jiraImporter: jiraImporter; - withUserEmailDomain: emailDomain; - user: user. - - metricUser loadProjects. - metricUser ]). + + users do: [ :user | + |projects | + projects := glhImporter importContributedProjectsOfUser: user. + projects do: [ :project | + glhImporter completeImportProject: project ]. + + ]. + + entities addAll: users. ^ self ] diff --git a/src/GitLabHealth-Model-Analysis/MergedMergeRequestWithoutReviewMetric.class.st b/src/GitLabHealth-Model-Analysis/MergedMergeRequestWithoutReviewMetric.class.st index 0c19679..4371515 100644 --- a/src/GitLabHealth-Model-Analysis/MergedMergeRequestWithoutReviewMetric.class.st +++ b/src/GitLabHealth-Model-Analysis/MergedMergeRequestWithoutReviewMetric.class.st @@ -52,7 +52,7 @@ MergedMergeRequestWithoutReviewMetric >> description [ { #category : #loading } MergedMergeRequestWithoutReviewMetric >> load [ - userMergeRequests := user + userMergeRequests := self loadCompleteMergeRequestsSince: (period at: #since) until: (period at: #until) diff --git a/src/GitLabHealth-Model-Analysis/Metric.class.st b/src/GitLabHealth-Model-Analysis/Metric.class.st index ad447f9..912cf06 100644 --- a/src/GitLabHealth-Model-Analysis/Metric.class.st +++ b/src/GitLabHealth-Model-Analysis/Metric.class.st @@ -3,7 +3,9 @@ Class { #superclass : #Object, #instVars : [ 'period', - 'over' + 'over', + 'glhImporter', + 'jiraImporter' ], #category : #'GitLabHealth-Model-Analysis' } @@ -20,6 +22,18 @@ Metric >> description [ ^ self subclassResponsibility ] +{ #category : #accessing } +Metric >> glhImporter: anObject [ + + glhImporter := anObject +] + +{ #category : #accessing } +Metric >> jiraImporter: anObject [ + + jiraImporter := anObject +] + { #category : #loading } Metric >> load [ ^self subclassResponsibility diff --git a/src/GitLabHealth-Model-Analysis/UserCommitsMetric.class.st b/src/GitLabHealth-Model-Analysis/UserCommitsMetric.class.st index 843d94a..c4fe087 100644 --- a/src/GitLabHealth-Model-Analysis/UserCommitsMetric.class.st +++ b/src/GitLabHealth-Model-Analysis/UserCommitsMetric.class.st @@ -19,7 +19,7 @@ UserCommitsMetric >> description [ { #category : #loading } UserCommitsMetric >> load [ - userCommits := user + userCommits := self loadCommitsSince: (period at: #since) until: (period at: #until) ] diff --git a/src/GitLabHealth-Model-Analysis/UserJiraMetric.class.st b/src/GitLabHealth-Model-Analysis/UserJiraMetric.class.st index 1f0ccac..b09b6f2 100644 --- a/src/GitLabHealth-Model-Analysis/UserJiraMetric.class.st +++ b/src/GitLabHealth-Model-Analysis/UserJiraMetric.class.st @@ -19,7 +19,7 @@ UserJiraMetric >> description [ { #category : #loading } UserJiraMetric >> load [ - userMergeRequests := user + userMergeRequests := self loadMergeRequestsWithJiraIssueSince: (period at: #since) until: (period at: #until) diff --git a/src/GitLabHealth-Model-Analysis/UserMergeRequestMetric.class.st b/src/GitLabHealth-Model-Analysis/UserMergeRequestMetric.class.st index 056fad9..c9f94e9 100644 --- a/src/GitLabHealth-Model-Analysis/UserMergeRequestMetric.class.st +++ b/src/GitLabHealth-Model-Analysis/UserMergeRequestMetric.class.st @@ -19,7 +19,7 @@ UserMergeRequestMetric >> description [ { #category : #loading } UserMergeRequestMetric >> load [ - userMergeRequests := user + userMergeRequests := self loadMergeRequestsSince: (period at: #since) until: (period at: #until) ] diff --git a/src/GitLabHealth-Model-Analysis/UserMetric.class.st b/src/GitLabHealth-Model-Analysis/UserMetric.class.st index d2ae287..4cbabfc 100644 --- a/src/GitLabHealth-Model-Analysis/UserMetric.class.st +++ b/src/GitLabHealth-Model-Analysis/UserMetric.class.st @@ -3,9 +3,9 @@ Class { #superclass : #Metric, #instVars : [ 'user', - 'userProjects', 'userCommits', - 'userMergeRequests' + 'userMergeRequests', + 'emailDomain' ], #category : #'GitLabHealth-Model-Analysis' } @@ -29,6 +29,34 @@ UserMetric >> description [ ^ self subclassResponsibility ] +{ #category : #accessing } +UserMetric >> emailDomain: anObject [ + + emailDomain := anObject +] + +{ #category : #churn } +UserMetric >> foundSuccessorOf: commits andCompleteImportForMax: commitLimit [ + + | analyzingCommits i size | + analyzingCommits := Set new. + glhImporter withCommitDiffs: true. + + commits do: [ :c | + GitAnalyzer new + visitChildCommits: c childCommits + toStoreThemIn: analyzingCommits + upto: commitLimit ]. + + i := 0. + size := analyzingCommits size. + analyzingCommits do: [ :c | + + glhImporter completeImportedCommit: c ]. + + ^ analyzingCommits +] + { #category : #initialization } UserMetric >> initialize [ over := Date @@ -40,6 +68,106 @@ UserMetric >> load [ ^ self subclassResponsibility ] +{ #category : #loading } +UserMetric >> loadCommitsSince: since until: until [ + + | cacheSymbol allCommits | + glhImporter withCommitDiffs: false. + + cacheSymbol := self + cacheSymbolFor: GLHCommit + since: since + until: until. + + "download commits unless project cache is not empty" + allCommits := user contributedProjects collect: [ :project | + project repository + cacheAt: cacheSymbol + ifAbsentPut: [ + | foundCommits | + foundCommits := glhImporter + importCommitsOProject: project + since: since + until: until. + foundCommits ] ]. + + allCommits := allCommits flatten. + allCommits do: [ :commit | glhImporter importCreatorOfCommit: commit ]. + glhImporter chainsCommitsFrom: allCommits. + glhImporter withCommitDiffs: true. + + ^allCommits reject: [ :commit | + commit commitCreator ~= user ] +] + +{ #category : #loading } +UserMetric >> loadCompleteCommitsSince: since until: until [ + + | commits | + commits := self loadCommitsSince: since until: until. + commits do: [ :commit | glhImporter completeImportedCommit: commit ]. + ^ commits +] + +{ #category : #loading } +UserMetric >> loadCompleteMergeRequestsSince: since until: until [ + + | mergeRequests | + mergeRequests := self loadMergeRequestsSince: since until: until. + + mergeRequests do: [ :mergeRequest | + glhImporter importMergeResquestMerger: mergeRequest ]. + + ^ mergeRequests +] + +{ #category : #loading } +UserMetric >> loadMergeRequestsSince: since until: until [ + + | cacheSymbol mergeRequests | + glhImporter withCommitDiffs: false. + cacheSymbol := self + cacheSymbolFor: GLPHEMergeRequest + since: since + until: until. + + mergeRequests := user contributedProjects collect: [ :project | + | mr | + project cacheAt: cacheSymbol ifAbsentPut: [ + mr := glhImporter + importMergeRequests: project + since: since + until: until. + mr ] ]. + + mergeRequests := mergeRequests flattened. + glhImporter withCommitDiffs: true. + + mergeRequests do: [ :mr | glhImporter importMergeResquestAuthor: mr ]. + + ^mergeRequests select: [ :mergeRequest | + mergeRequest author = user ]. +] + +{ #category : #loading } +UserMetric >> loadMergeRequestsWithJiraIssueSince: since until: until [ + + | email mergeRequests | + mergeRequests := self loadMergeRequestsSince: since until: until. + + email := self userEmail. + + jiraImporter importAllCurrentAndPastIssuesOf: email. + + GPJCConnector new + gpModel: glhImporter glhModel; + jiraModel: jiraImporter model; + connect. + + ^ mergeRequests select: [ :mergeRequest | + mergeRequest jiraIssue isNotNil ] +] + { #category : #accessing } UserMetric >> name [ @@ -51,3 +179,10 @@ UserMetric >> user: anObject [ user := anObject ] + +{ #category : #email } +UserMetric >> userEmail [ + ^ ('' join: { + user username. + emailDomain }) asLowercase +]