Skip to content

Commit 012a80f

Browse files
authored
Merge pull request #44 from moosetechnology/feature-jira-email
Feature jira email
2 parents 52305cb + 73a69b0 commit 012a80f

File tree

4 files changed

+51
-12
lines changed

4 files changed

+51
-12
lines changed

src/GitLabHealth-Model-Analysis/GLHUserCatalogueV2.class.st

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,21 @@ GLHUserCatalogueV2 class >> loadFromJson: aString [
1111
catalogue := self new.
1212
dic := (STONJSON fromString: aString) asDictionary.
1313
dic associationsDo: [ :assoc |
14-
| itsName itsUsername itsCommitNames itsId|
14+
| itsName itsUsername itsCommitNames itsId |
1515
itsName := assoc key.
1616
itsCommitNames := assoc value at: #foundNames.
17-
itsUsername := assoc value at: #username.
17+
itsUsername := assoc value at: #username.
1818
itsId := assoc value at: #id.
19-
20-
catalogue addUser: (GLHUser new id: itsId; username: itsUsername; name: itsName; yourself ) withNames: itsCommitNames ].
21-
22-
^ catalogue .
19+
20+
catalogue
21+
addUser: (GLHUser new
22+
id: itsId;
23+
username: itsUsername;
24+
name: itsName;
25+
yourself)
26+
withNames: itsCommitNames ].
27+
28+
^ catalogue
2329
]
2430

2531
{ #category : #'as yet unclassified' }

src/GitLabHealth-Model-Analysis/GitMetric4User.class.st

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,26 @@ Class {
33
#superclass : #GitMetric,
44
#instVars : [
55
'itsCommits',
6-
'itsMergeRequests'
6+
'itsMergeRequests',
7+
'emailDomain'
78
],
89
#category : #'GitLabHealth-Model-Analysis'
910
}
1011

12+
{ #category : #'email' }
13+
GitMetric4User >> withUserEmailDomain: aEmailDomain [
14+
emailDomain := aEmailDomain.
15+
]
16+
17+
{ #category : #'email' }
18+
GitMetric4User >> userEmail [
19+
"overide this method to adapt on your situation"
20+
21+
^ ('' join: {
22+
user username.
23+
emailDomain }) asLowercase.
24+
]
25+
1126
{ #category : #'metrics - commits' }
1227
GitMetric4User >> averageTimeBetweenCommitSince: since until: until overA: aDateWeekMonthOrYear [
1328

@@ -663,7 +678,9 @@ GitMetric4User >> initialize [
663678
user := GLHUser new.
664679
itsProjects := Dictionary new.
665680
itsCommits := Dictionary new.
666-
itsMergeRequests := Dictionary new
681+
itsMergeRequests := Dictionary new.
682+
683+
emailDomain := '@generic-domain.com'
667684
]
668685

669686
{ #category : #accessing }
@@ -691,12 +708,15 @@ GitMetric4User >> loadCommitOfProjects: aCollection since: aTimespan [
691708
{ #category : #loading }
692709
GitMetric4User >> loadItsMergeRequesWithJiraIssueSince: since until: until [
693710

711+
|email|
694712
itsMergeRequests := self
695713
loadItsMergeRequestsSince: since
696714
until: until.
697715

716+
email := self userEmail.
717+
698718
jiraImporter importAllCurrentAndPastIssuesOf:
699-
user commits anyOne author_email.
719+
email.
700720

701721
GPJCConnector new
702722
gpModel: glhImporter glhModel;

src/GitLabHealth-Model-Analysis/GitMetricExporter.class.st

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@ Class {
1111
'runningPeriods',
1212
'maxCommitWindow',
1313
'over',
14-
'analyses'
14+
'analyses',
15+
'emailDomain'
1516
],
1617
#category : #'GitLabHealth-Model-Analysis'
1718
}
1819

20+
21+
1922
{ #category : #'as yet unclassified' }
2023
GitMetricExporter class >> demoPeriod [
2124

@@ -25,6 +28,13 @@ GitMetricExporter class >> demoPeriod [
2528
addAPeriodFrom: '01 march 2024' to: '31 may 2024'
2629
]
2730

31+
{ #category : #setup }
32+
GitMetricExporter >> withEmailDomain: anEmailDomain [
33+
34+
"define the email domain of your Git user. Usefull to link them between service (i.e. Jira)"
35+
emailDomain := anEmailDomain
36+
]
37+
2838
{ #category : #adding }
2939
GitMetricExporter >> addAPeriodFrom: since to: until [
3040

@@ -469,7 +479,7 @@ GitMetricExporter >> onlyImportProjectsOfGroup: groupId [
469479
projectCache := group toScope: GLHProject
470480
]
471481

472-
{ #category : #adding }
482+
{ #category : #setup }
473483
GitMetricExporter >> setupAnalysisForUsersWithNames: userNames [
474484
"import all the project since a certain time"
475485

@@ -486,6 +496,8 @@ GitMetricExporter >> setupAnalysisForUsersWithNames: userNames [
486496
metrics := GitMetric4User new.
487497
metrics
488498
glhImporter: glhImporter;
499+
jiraImporter: jiraImporter;
500+
withUserEmailDomain: emailDomain;
489501
user: user.
490502

491503
i := 0.

src/GitLabHealth-Model-Importer/GLHModelImporter.class.st

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,8 @@ GLHModelImporter >> userCatalogue [
11551155
{ #category : #accessing }
11561156
GLHModelImporter >> userCatalogue: aGLHUserCatalogue [
11571157

1158-
userCatalogue := aGLHUserCatalogue
1158+
userCatalogue := aGLHUserCatalogue.
1159+
aGLHUserCatalogue anImporter: self.
11591160
]
11601161

11611162
{ #category : #accessing }

0 commit comments

Comments
 (0)