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

fix: jiraTimeMRTimeDifferenceMetric error on 2 period #66

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -51,6 +51,50 @@ JiraTimeMRTimeDifferenceMetricTest >> testCalculate [
self assert: result equals: 1 hours asSeconds
]

{ #category : #tests }
JiraTimeMRTimeDifferenceMetricTest >> testCalculate2PeriodWith1EmptyPeriod [

| result glhImporter user jiraImporter jiraMRDifference |
"Given"
user := GLHUser new
username: 'test';
contributedProjects:
{ (GLHProject new repository: GLHRepository new) }.

glhImporter := GLPHImporterMock new.
glhImporter mergeRequests: { (GLPHEMergeRequest new
author: user;
created_at: '09-05-2024';
merged_at: '09-06-2024' asDate;
title: '205 feat do something') }.

glhImporter commits: { (GLHCommit new
id: 1;
created_at: '09-05-2024' asDate;
commitCreator: user;
deletions: 5) }.

jiraImporter := JiraImporterMock new.
jiraImporter issues: { (JPIssue new
key: '205';
timeEstimate: 25 hours asDuration) }.


jiraMRDifference := JiraTimeMRTimeDifferenceMetric new
user: user;
glhImporter: glhImporter;
jiraImporter: jiraImporter;
setPeriodSince: '09-04-2024'
until: '09-09-2024';
over: Week.

"When"
result := jiraMRDifference calculate.

"Then"
self assert: result equals: 1 hours /2 asSeconds
]

{ #category : #tests }
JiraTimeMRTimeDifferenceMetricTest >> testCalculateNoMergeRequests [

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ JiraTimeMRTimeDifferenceMetric >> calculate [

| groupedByDate dateOver |
userMergeRequests ifNil: [ self load ].
userMergeRequests ifEmpty: [ ^nil ].
userMergeRequests ifEmpty: [ ^ nil ].
groupedByDate := self setupGroupedDate.

userMergeRequests do: [ :userMergeRequest |
Expand All @@ -19,7 +19,7 @@ JiraTimeMRTimeDifferenceMetric >> calculate [
ifPresent: [ :value | value add: userMergeRequest ] ].

groupedByDate := groupedByDate collect: [ :group |
| differences |
| differences average |
differences := group collect: [ :mergeRequest |
| firstCommitDate mergeRequestTime jiraTime |
firstCommitDate := mergeRequest
Expand All @@ -42,9 +42,13 @@ JiraTimeMRTimeDifferenceMetric >> calculate [

(jiraTime - mergeRequestTime)
asSeconds ].
differences average ].

average := group ifEmpty: [ 0 ] ifNotEmpty: [ differences average ].
average
].

^ groupedByDate average

^ groupedByDate average
]

{ #category : #accessing }
Expand Down
Loading