Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
f3791135
Commit
f3791135
authored
Apr 03, 2020
by
Bob van de Vijver
Committed by
Kushal Pandya
Apr 03, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #22622: Include MR times in Milestone time overview
parent
972e5e68
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
59 additions
and
19 deletions
+59
-19
app/models/concerns/milestoneish.rb
app/models/concerns/milestoneish.rb
+8
-8
app/models/global_milestone.rb
app/models/global_milestone.rb
+1
-1
app/views/shared/milestones/_sidebar.html.haml
app/views/shared/milestones/_sidebar.html.haml
+4
-4
changelogs/unreleased/include-mr-times.yml
changelogs/unreleased/include-mr-times.yml
+5
-0
doc/user/project/milestones/index.md
doc/user/project/milestones/index.md
+1
-1
spec/models/concerns/milestoneish_spec.rb
spec/models/concerns/milestoneish_spec.rb
+40
-5
No files found.
app/models/concerns/milestoneish.rb
View file @
f3791135
...
...
@@ -117,20 +117,20 @@ module Milestoneish
false
end
def
total_
issue_
time_spent
@total_
issue_time_spent
||=
issue
s
.
joins
(
:timelogs
).
sum
(
:time_spent
)
def
total_time_spent
@total_
time_spent
||=
issues
.
joins
(
:timelogs
).
sum
(
:time_spent
)
+
merge_request
s
.
joins
(
:timelogs
).
sum
(
:time_spent
)
end
def
human_total_
issue_
time_spent
Gitlab
::
TimeTrackingFormatter
.
output
(
total_
issue_
time_spent
)
def
human_total_time_spent
Gitlab
::
TimeTrackingFormatter
.
output
(
total_time_spent
)
end
def
total_
issue_
time_estimate
@total_
issue_time_estimate
||=
issue
s
.
sum
(
:time_estimate
)
def
total_time_estimate
@total_
time_estimate
||=
issues
.
sum
(
:time_estimate
)
+
merge_request
s
.
sum
(
:time_estimate
)
end
def
human_total_
issue_
time_estimate
Gitlab
::
TimeTrackingFormatter
.
output
(
total_
issue_
time_estimate
)
def
human_total_time_estimate
Gitlab
::
TimeTrackingFormatter
.
output
(
total_time_estimate
)
end
private
...
...
app/models/global_milestone.rb
View file @
f3791135
...
...
@@ -94,7 +94,7 @@ class GlobalMilestone
end
def
merge_requests
@merge_requests
||=
MergeRequest
.
of_milestones
(
milestone
).
includes
(
:target_project
,
:assignee
,
:labels
)
@merge_requests
||=
MergeRequest
.
of_milestones
(
milestone
).
includes
(
:target_project
,
:assignee
s
,
:labels
)
end
def
labels
...
...
app/views/shared/milestones/_sidebar.html.haml
View file @
f3791135
...
...
@@ -93,10 +93,10 @@
=
milestone
.
issues_visible_to_user
(
current_user
).
closed
.
count
.block
#issuable-time-tracker
{
data:
{
time_estimate:
@milestone
.
total_
issue_
time_estimate
,
time_spent:
@milestone
.
total_
issue_
time_spent
,
human_time_estimate:
@milestone
.
human_total_
issue_
time_estimate
,
human_time_spent:
@milestone
.
human_total_
issue_
time_spent
,
#issuable-time-tracker
{
data:
{
time_estimate:
@milestone
.
total_time_estimate
,
time_spent:
@milestone
.
total_time_spent
,
human_time_estimate:
@milestone
.
human_total_time_estimate
,
human_time_spent:
@milestone
.
human_total_time_spent
,
limit_to_hours:
Gitlab
::
CurrentSettings
.
time_tracking_limit_to_hours
.
to_s
}
}
=
render_if_exists
'shared/milestones/weight'
,
milestone:
milestone
...
...
changelogs/unreleased/include-mr-times.yml
0 → 100755
View file @
f3791135
---
title
:
Include MR times in Milestone time overview
merge_request
:
28519
author
:
Bob van de Vijver
type
:
fixed
doc/user/project/milestones/index.md
View file @
f3791135
...
...
@@ -133,7 +133,7 @@ The milestone sidebar on the milestone view shows the following:
-
Percentage complete, which is calculated as number of closed issues divided by total number of issues.
-
The start date and due date.
-
The total time spent on all issues assigned to the milestone.
-
The total time spent on all issues a
nd merge requests a
ssigned to the milestone.
-
The total issue weight of all issues assigned to the milestone.
![
Project milestone page
](
img/milestones_project_milestone_page.png
)
...
...
spec/models/concerns/milestoneish_spec.rb
View file @
f3791135
...
...
@@ -302,20 +302,55 @@ describe Milestone, 'Milestoneish' do
end
end
describe
'#total_
issue_
time_spent'
do
it
'calculates total
issue
time spent'
do
describe
'#total_time_spent'
do
it
'calculates total time spent'
do
closed_issue_1
.
spend_time
(
duration:
300
,
user_id:
author
.
id
)
closed_issue_1
.
save!
closed_issue_2
.
spend_time
(
duration:
600
,
user_id:
assignee
.
id
)
closed_issue_2
.
save!
expect
(
milestone
.
total_issue_time_spent
).
to
eq
(
900
)
expect
(
milestone
.
total_time_spent
).
to
eq
(
900
)
end
it
'includes merge request time spent'
do
closed_issue_1
.
spend_time
(
duration:
300
,
user_id:
author
.
id
)
closed_issue_1
.
save!
merge_request
.
spend_time
(
duration:
900
,
user_id:
author
.
id
)
merge_request
.
save!
expect
(
milestone
.
total_time_spent
).
to
eq
(
1200
)
end
end
describe
'#human_total_time_spent'
do
it
'returns nil if no time has been spent'
do
expect
(
milestone
.
human_total_time_spent
).
to
be_nil
end
end
describe
'#total_time_estimate'
do
it
'calculates total estimate'
do
closed_issue_1
.
time_estimate
=
300
closed_issue_1
.
save!
closed_issue_2
.
time_estimate
=
600
closed_issue_2
.
save!
expect
(
milestone
.
total_time_estimate
).
to
eq
(
900
)
end
it
'includes merge request time estimate'
do
closed_issue_1
.
time_estimate
=
300
closed_issue_1
.
save!
merge_request
.
time_estimate
=
900
merge_request
.
save!
expect
(
milestone
.
total_time_estimate
).
to
eq
(
1200
)
end
end
describe
'#human_total_
issue_time_spent
'
do
describe
'#human_total_
time_estimate
'
do
it
'returns nil if no time has been spent'
do
expect
(
milestone
.
human_total_
issue_time_spent
).
to
be_nil
expect
(
milestone
.
human_total_
time_estimate
).
to
be_nil
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment