Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #95

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5b77080
put model importer inside super class
Sep 26, 2024
56314d3
Merge pull request #78 from moosetechnology/fix/model-importer
alkalinan Oct 7, 2024
22e5196
do not compute diff when server return error
badetitou Oct 7, 2024
1b1a264
Merge pull request #79 from moosetechnology/feature/error-with-bigdif…
badetitou Oct 7, 2024
947135b
enable diff range importer for Bitbucket
Oct 7, 2024
f2eb25d
add repoAPI to abstract importer; working on usercatalogue for bitbucket
Oct 8, 2024
8e34931
changing catalogue user importation for bitbucket
Oct 8, 2024
f7b43a8
Merge pull request #80 from moosetechnology/feature/commitImportBitBu…
alkalinan Oct 8, 2024
ae211a7
renaming for consistencies; fix visu case of no commits
Oct 10, 2024
5e7ee19
fix author color in commit tree visu. renaming bitbucket api method
Oct 10, 2024
6d97827
using none deprecated method
Oct 10, 2024
31cd73f
revert user: renaming; fixing on commit diff parsing
Oct 10, 2024
7276be9
fix model importer for bitbucket commit
Oct 10, 2024
eb3f2ec
deporecate repo api
badetitou Oct 11, 2024
93c7f60
Merge pull request #82 from moosetechnology/deprecate-repoapi
badetitou Oct 11, 2024
fdc3ac5
Merge pull request #81 from moosetechnology/refactoring/rename
badetitou Oct 11, 2024
85ac28a
add commit diff import for github importer
Oct 14, 2024
c6f44c1
add diff range parsing
Oct 14, 2024
74be8a8
add temp merge request importer
Oct 14, 2024
8a7e96d
fix deprecated names
Oct 15, 2024
f3f3234
fix: change userEmail to accept public_email by default
knowbased Oct 16, 2024
bb4dcf3
fix: additions are nil in commits import with importMergeRequestCommits
knowbased Oct 16, 2024
2691475
another renaming of deprecated method
Oct 16, 2024
b808647
Merge pull request #83 from moosetechnology/feature/commitdiff-github…
alkalinan Oct 16, 2024
833d56a
Merge pull request #84 from moosetechnology/fix/jira-metrics-not-work…
alkalinan Oct 16, 2024
1cf9744
feat: code addition and code deletion by merge request metric
knowbased Oct 17, 2024
b01d3f3
feat(GitMetricExporter): add code addition and deletion by mr metrics…
knowbased Oct 17, 2024
8b0a65f
add complete commit import to bitbucket methods (#86)
alkalinan Oct 17, 2024
ed0b8fb
Merge pull request #85 from moosetechnology/feat/code-contribution-by-mr
badetitou Oct 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ BitBucketModelImporterTest >> testGetContributionFromDiffsWithoutRemoved [
{ #category : #tests }
BitBucketModelImporterTest >> testImportCommitsOfProjectSinceUntil [

| bitBucketApi glphModel bitBucketImporter project commits group repo |
| bitBucketApi glphModel bitBucketImporter project commits group repo firstCommit |
"Given"
bitBucketApi := BitBucketApiMock new.

Expand All @@ -160,8 +160,10 @@ BitBucketModelImporterTest >> testImportCommitsOfProjectSinceUntil [
self
assert: (bitBucketImporter glhModel allWithType: GLHCommit) size
equals: 1.

self assert: project repository commits size equals: 1.

self assert: project repository commits size equals: 1.
firstCommit := project repository commits first.
self assert: firstCommit additions equals: 1
]

{ #category : #tests }
Expand Down Expand Up @@ -282,7 +284,8 @@ BitBucketModelImporterTest >> testImportMergeRequestCommits [

"Then"
self deny: mergeRequest commits equals: nil.
self assert: mergeRequest commits equals: commits
self assert: mergeRequest commits equals: commits.
self assert: mergeRequest commits first additions equals: 1
]

{ #category : #tests }
Expand Down
44 changes: 25 additions & 19 deletions src/BitBucketHealth-Model-Importer/BitBucketModelImporter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -174,22 +174,18 @@ BitBucketModelImporter >> importCommitsOfProject: aGLHProject since: since until
until: until.

commits := commits collect: [ :commit |
| glhCommit commitDiffs contribution |
glhCommit := self parseCommitIntoGLHCommit: commit.
commitDiffs := self repoApi
diffsOfCommit: glhCommit id
inRepoProjectId: aGLHProject id
inProjectGroupId: aGLHProject group id.

contribution := self getContributionFromDiffs:
(commitDiffs at: #diffs).
glhCommit additions: (contribution at: #additions).
glhCommit deletions: (contribution at: #deletions).
glhCommit ].

self parseCommitIntoGLHCommit: commit ofProject: aGLHProject.


commits := self glhModel addAll: commits unless: self blockOnIdEquality.
^ aGLHProject repository commits addAll: commits unless: self blockOnIdEquality.
].


commits := self glhModel
addAll: commits
unless: self blockOnIdEquality.
^ aGLHProject repository commits
addAll: commits
unless: self blockOnIdEquality
]

{ #category : #'import - projects' }
Expand Down Expand Up @@ -301,7 +297,7 @@ BitBucketModelImporter >> importMergeRequestCommits: mergeRequest [
inProjectGroupId: mergeRequest project group id.

commits := commits collect: [ :commit |
self parseCommitIntoGLHCommit: commit ].
self parseCommitIntoGLHCommit: commit ofProject: mergeRequest project ].

mergeRequest commits: commits.

Expand Down Expand Up @@ -384,15 +380,23 @@ BitBucketModelImporter >> importUserByUsername: username [
]

{ #category : #parsing }
BitBucketModelImporter >> parseCommitIntoGLHCommit: commitDictionary [
BitBucketModelImporter >> parseCommitIntoGLHCommit: commitDictionary ofProject: aGLHProject [

| author committer parentIds |
| author committer parentIds commitDiffs contribution |
author := commitDictionary at: #author.
committer := commitDictionary at: #committer.

parentIds := (commitDictionary at: #parents) collect: [ :parent |
parent at: #id ].

commitDiffs := self repoApi
diffsOfCommit: (commitDictionary at: #id)
inRepoProjectId: aGLHProject id
inProjectGroupId: aGLHProject group id.

contribution := self getContributionFromDiffs:
(commitDiffs at: #diffs).

^ GLHCommit new
id: (commitDictionary at: #id);
message: (commitDictionary at: #message);
Expand All @@ -406,7 +410,9 @@ BitBucketModelImporter >> parseCommitIntoGLHCommit: commitDictionary [
(commitDictionary at: #committerTimestamp) / 1000);
committer_email: (committer at: #emailAddress);
committer_name: (committer at: #name);
parent_ids: parentIds
parent_ids: parentIds;
additions: (contribution at: #additions);
deletions: (contribution at: #deletions)
]

{ #category : #parsing }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ CodeAdditionByTicketMetric >> calculate [

| groupedByDate dateOver |
userMergeRequests ifNil: [ self load ].

groupedByDate := self setupGroupedDate.
userMergeRequests ifEmpty: [ ^ 0 ].

Expand All @@ -19,11 +20,11 @@ CodeAdditionByTicketMetric >> calculate [
at: dateOver printString
ifPresent: [ :value | value add: userMergeRequest ] ].

groupedByDate := groupedByDate collect: [ :group |
| average |
average := (group collect: [ :mergeRequest | mergeRequest commits sum: [ :commit | commit additions ] ]) average
].
groupedByDate := groupedByDate collect: [ :group |
| average |
average := (group collect: [ :mergeRequest |
mergeRequest commits sum: [ :commit |
commit additions ] ]) average ].

^ groupedByDate average asFloat
]
Expand All @@ -40,5 +41,5 @@ CodeAdditionByTicketMetric >> load [
userMergeRequests := self
loadUserCompleteMergeRequestsWithJiraIssueSince:
(period at: #since)
until: (period at: #until).
until: (period at: #until)
]
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ CodeDeletionByTicketMetric >> calculate [

| groupedByDate dateOver |
userMergeRequests ifNil: [ self load ].

groupedByDate := self setupGroupedDate.
userMergeRequests ifEmpty: [ ^ 0 ].

Expand Down
2 changes: 1 addition & 1 deletion src/GitLabHealth-Model-Analysis/GitMetricExporter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ GitMetricExporter >> generateUsersAnalysesDuringPeriod: period over: aDateWeekMo
until: (period at: #until);
over: aDateWeekMonthOrYear;
user: user;
emailDomain: emailDomain.
emailDomain: emailDomain.


result := newMetric calculate.
Expand Down
7 changes: 6 additions & 1 deletion src/GitLabHealth-Model-Analysis/UserMetric.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ UserMetric >> loadUserCompleteMergeRequestsSince: since until: until [
UserMetric >> loadUserCompleteMergeRequestsWithJiraIssueSince: since until: until [

| email mergeRequests |
mergeRequests := self loadUserCompleteMergeRequestsSince: since until: until.
mergeRequests := self
loadUserCompleteMergeRequestsSince: since
until: until.

email := self userEmail.

Expand Down Expand Up @@ -244,6 +246,9 @@ UserMetric >> user: anObject [

{ #category : #email }
UserMetric >> userEmail [

user public_email = '' ifFalse: [ ^ user public_email ].

^ ('' join: {
user username.
emailDomain }) asLowercase
Expand Down
Loading