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
d27da27b
Commit
d27da27b
authored
Nov 06, 2017
by
George Andrinopoulos
Committed by
Winnie Hellmann
Nov 13, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move total time spend calculation to milestoneish
parent
d2fe9f2b
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
24 additions
and
77 deletions
+24
-77
app/models/concerns/milestoneish.rb
app/models/concerns/milestoneish.rb
+8
-0
app/models/global_milestone.rb
app/models/global_milestone.rb
+0
-8
app/models/milestone.rb
app/models/milestone.rb
+0
-8
app/views/shared/milestones/_sidebar.html.haml
app/views/shared/milestones/_sidebar.html.haml
+5
-5
spec/models/concerns/milestoneish_spec.rb
spec/models/concerns/milestoneish_spec.rb
+11
-0
spec/models/global_milestone_spec.rb
spec/models/global_milestone_spec.rb
+0
-33
spec/models/milestone_spec.rb
spec/models/milestone_spec.rb
+0
-23
No files found.
app/models/concerns/milestoneish.rb
View file @
d27da27b
...
@@ -86,6 +86,14 @@ module Milestoneish
...
@@ -86,6 +86,14 @@ module Milestoneish
false
false
end
end
def
total_issue_time_spent
issues
.
joins
(
:timelogs
).
sum
(
:time_spent
)
end
def
human_total_issue_time_spent
Gitlab
::
TimeTrackingFormatter
.
output
(
total_issue_time_spent
)
end
private
private
def
count_issues_by_state
(
user
)
def
count_issues_by_state
(
user
)
...
...
app/models/global_milestone.rb
View file @
d27da27b
...
@@ -152,12 +152,4 @@ class GlobalMilestone
...
@@ -152,12 +152,4 @@ class GlobalMilestone
@milestones
.
first
.
start_date
@milestones
.
first
.
start_date
end
end
end
end
def
total_time_spent
issues
.
joins
(
:timelogs
).
sum
(
:time_spent
)
+
merge_requests
.
joins
(
:timelogs
).
sum
(
:time_spent
)
end
def
human_total_time_spent
Gitlab
::
TimeTrackingFormatter
.
output
(
total_time_spent
)
end
end
end
app/models/milestone.rb
View file @
d27da27b
...
@@ -213,14 +213,6 @@ class Milestone < ActiveRecord::Base
...
@@ -213,14 +213,6 @@ class Milestone < ActiveRecord::Base
project_id
.
present?
project_id
.
present?
end
end
def
total_time_spent
issues
.
joins
(
:timelogs
).
sum
(
:time_spent
)
+
merge_requests
.
joins
(
:timelogs
).
sum
(
:time_spent
)
end
def
human_total_time_spent
Gitlab
::
TimeTrackingFormatter
.
output
(
total_time_spent
)
end
private
private
# Milestone titles must be unique across project milestones and group milestones
# Milestone titles must be unique across project milestones and group milestones
...
...
app/views/shared/milestones/_sidebar.html.haml
View file @
d27da27b
...
@@ -89,15 +89,15 @@
...
@@ -89,15 +89,15 @@
.sidebar-collapsed-icon
.sidebar-collapsed-icon
=
custom_icon
(
'icon_hourglass'
)
=
custom_icon
(
'icon_hourglass'
)
%span
.collapsed-milestone-total-time-spent
%span
.collapsed-milestone-total-time-spent
-
if
milestone
.
human_total_time_spent
-
if
milestone
.
human_total_
issue_
time_spent
=
milestone
.
human_total_time_spent
=
milestone
.
human_total_
issue_
time_spent
-
else
-
else
None
None
.title.hide-collapsed
.title.hide-collapsed
Total time spent
Total
issue
time spent
.value.hide-collapsed
.value.hide-collapsed
-
if
milestone
.
human_total_time_spent
-
if
milestone
.
human_total_
issue_
time_spent
%span
.bold
=
milestone
.
human_total_time_spent
%span
.bold
=
milestone
.
human_total_
issue_
time_spent
-
else
-
else
%span
.no-value
No time spent
%span
.no-value
No time spent
...
...
spec/models/concerns/milestoneish_spec.rb
View file @
d27da27b
...
@@ -186,4 +186,15 @@ describe Milestone, 'Milestoneish' do
...
@@ -186,4 +186,15 @@ describe Milestone, 'Milestoneish' do
expect
(
milestone
.
elapsed_days
).
to
eq
(
2
)
expect
(
milestone
.
elapsed_days
).
to
eq
(
2
)
end
end
end
end
describe
'#total_issue_time_spent'
do
it
'calculates total issue time spent'
do
closed_issue_1
.
spend_time
(
duration:
300
,
user:
author
)
closed_issue_1
.
save!
closed_issue_2
.
spend_time
(
duration:
600
,
user:
assignee
)
closed_issue_2
.
save!
expect
(
milestone
.
total_issue_time_spent
).
to
eq
(
900
)
end
end
end
end
spec/models/global_milestone_spec.rb
View file @
d27da27b
...
@@ -190,37 +190,4 @@ describe GlobalMilestone do
...
@@ -190,37 +190,4 @@ describe GlobalMilestone do
end
end
end
end
end
end
describe
'#total_time_spent'
do
let
(
:milestone1_project1
)
{
create
(
:milestone
,
title:
"Milestone v1.2"
,
project:
project1
)
}
let
(
:milestone1_project2
)
{
create
(
:milestone
,
title:
"Milestone v1.2"
,
project:
project2
)
}
let
(
:issue1
)
{
create
(
:issue
,
milestone:
milestone1_project1
)
}
let
(
:issue2
)
{
create
(
:issue
,
milestone:
milestone1_project2
)
}
let
(
:merge_request1
)
{
create
(
:merge_request
,
milestone:
milestone1_project1
)
}
let
(
:merge_request2
)
{
create
(
:merge_request
,
milestone:
milestone1_project2
)
}
before
do
milestones
=
[
milestone1_project1
,
milestone1_project2
]
milestones_relation
=
Milestone
.
where
(
id:
milestones
.
map
(
&
:id
))
@global_milestone
=
described_class
.
new
(
milestone1_project1
.
title
,
milestones_relation
)
end
it
'calculates total time spent'
do
issue1
.
spend_time
(
duration:
300
,
user:
user
)
issue1
.
save!
issue2
.
spend_time
(
duration:
600
,
user:
user2
)
issue2
.
save!
merge_request1
.
spend_time
(
duration:
200
,
user:
user
)
merge_request1
.
save!
merge_request2
.
spend_time
(
duration:
100
,
user:
user2
)
merge_request2
.
save!
expect
(
@global_milestone
.
total_time_spent
).
to
eq
(
1200
)
end
end
end
end
spec/models/milestone_spec.rb
View file @
d27da27b
...
@@ -284,27 +284,4 @@ describe Milestone do
...
@@ -284,27 +284,4 @@ describe Milestone do
expect
(
milestone
.
participants
).
to
eq
[
user
]
expect
(
milestone
.
participants
).
to
eq
[
user
]
end
end
end
end
describe
'#total_time_spent'
do
let
(
:user
)
{
build
(
:user
)
}
let
(
:project
)
{
build
(
:project
,
name:
'sample-project'
)
}
let
(
:milestone
)
{
build
(
:milestone
,
iid:
1
,
project:
project
)
}
let
(
:issue1
)
{
build
(
:issue
,
milestone:
milestone
)
}
let
(
:issue2
)
{
build
(
:issue
,
milestone:
milestone
)
}
let
(
:merge_request1
)
{
build
(
:merge_request
,
milestone:
milestone
)
}
let
(
:merge_request2
)
{
build
(
:merge_request
,
milestone:
milestone
)
}
it
'calculates total time spent'
do
issue1
.
spend_time
(
duration:
300
,
user:
user
)
issue1
.
save!
issue2
.
spend_time
(
duration:
600
,
user:
user
)
issue2
.
save!
merge_request1
.
spend_time
(
duration:
200
,
user:
user
)
merge_request1
.
save!
merge_request2
.
spend_time
(
duration:
100
,
user:
user
)
merge_request2
.
save!
expect
(
milestone
.
total_time_spent
).
to
eq
(
1200
)
end
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