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
0
Merge Requests
0
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
Tatuya Kamada
gitlab-ce
Commits
0723bf1a
Commit
0723bf1a
authored
Jun 26, 2014
by
Marin Jankovski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move group milestone processing from service to model.
parent
8e8c0742
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
77 deletions
+53
-77
app/controllers/groups/milestones_controller.rb
app/controllers/groups/milestones_controller.rb
+1
-2
app/models/group_milestone.rb
app/models/group_milestone.rb
+41
-0
app/services/milestones/group_service.rb
app/services/milestones/group_service.rb
+3
-64
app/views/groups/milestones/index.html.haml
app/views/groups/milestones/index.html.haml
+8
-11
No files found.
app/controllers/groups/milestones_controller.rb
View file @
0723bf1a
...
@@ -5,8 +5,7 @@ class Groups::MilestonesController < ApplicationController
...
@@ -5,8 +5,7 @@ class Groups::MilestonesController < ApplicationController
@group
=
Group
.
find_by
(
path:
params
[
:group_id
])
@group
=
Group
.
find_by
(
path:
params
[
:group_id
])
project_ids
=
@group
.
projects
project_ids
=
@group
.
projects
project_milestones
=
Milestone
.
where
(
project_id:
project_ids
)
project_milestones
=
Milestone
.
where
(
project_id:
project_ids
)
@milestones
=
project_milestones
@group_milestones
=
Milestones
::
GroupService
.
new
(
project_milestones
).
execute
@group_milestones
=
Milestones
::
GroupService
.
new
(
@group
,
current_user
,
project_milestones
)
end
end
end
end
app/models/group_milestone.rb
0 → 100644
View file @
0723bf1a
class
GroupMilestone
def
initialize
(
title
,
milestones
)
@title
=
title
@milestones
=
milestones
end
def
title
@title
end
def
milestones
@milestones
end
def
project_names
milestones
.
map
{
|
milestone
|
milestone
.
project
.
name
}
end
def
issue_count
milestones
.
map
{
|
milestone
|
milestone
.
issues
.
count
}.
sum
end
def
merge_requests_count
milestones
.
map
{
|
milestone
|
milestone
.
merge_requests
.
count
}.
sum
end
def
closed_items_count
milestones
.
map
{
|
milestone
|
milestone
.
closed_items_count
}.
sum
end
def
total_items_count
milestones
.
map
{
|
milestone
|
milestone
.
total_items_count
}.
sum
end
def
percent_complete
((
closed_items_count
*
100
)
/
total_items_count
).
abs
rescue
ZeroDivisionError
100
end
end
app/services/milestones/group_service.rb
View file @
0723bf1a
module
Milestones
module
Milestones
class
GroupService
<
Milestones
::
BaseService
class
GroupService
<
Milestones
::
BaseService
def
initialize
(
group
,
user
,
project_milestones
)
def
initialize
(
project_milestones
)
@group
=
group
@user
=
user
@project_milestones
=
project_milestones
.
group_by
(
&
:title
)
@project_milestones
=
project_milestones
.
group_by
(
&
:title
)
end
end
def
titles
def
execute
@project_milestones
.
map
{
|
title
,
milestone
|
title
}
@project_milestones
.
map
{
|
title
,
milestone
|
GroupMilestone
.
new
(
title
,
milestone
)
}
end
def
project_names
names
=
{}
@project_milestones
.
map
do
|
title
,
milestone
|
projects
=
milestone
.
map
{
|
m
|
m
.
project
.
name
}
names
.
store
(
title
,
projects
)
end
names
end
def
issue_count
@project_milestones
.
merge
(
@project_milestones
){
|
title
,
milestone
|
milestone
.
map
{
|
m
|
m
.
issues
.
count
}.
sum
}
end
def
mr_count
@project_milestones
.
merge
(
@project_milestones
){
|
title
,
milestone
|
milestone
.
map
{
|
m
|
m
.
merge_requests
.
count
}.
sum
}
end
def
open_issues_count
@project_milestones
.
merge
(
@project_milestones
){
|
title
,
milestone
|
milestone
.
map
{
|
m
|
m
.
issues
.
opened
.
count
}.
sum
}
end
def
closed_issues_count
@project_milestones
.
merge
(
@project_milestones
){
|
title
,
milestone
|
milestone
.
map
{
|
m
|
m
.
issues
.
closed
.
count
}.
sum
}
end
def
open_mr_count
@project_milestones
.
merge
(
@project_milestones
){
|
title
,
milestone
|
milestone
.
map
{
|
m
|
m
.
merge_requests
.
opened
.
count
}.
sum
}
end
def
close_mr_count
@project_milestones
.
merge
(
@project_milestones
){
|
title
,
milestone
|
milestone
.
map
{
|
m
|
m
.
merge_requests
.
closed
.
count
}.
sum
}
end
def
open_items_count
@project_milestones
.
merge
(
@project_milestones
){
|
title
,
milestone
|
milestone
.
map
{
|
m
|
m
.
open_items_count
}.
sum
}
end
def
closed_items_count
@project_milestones
.
merge
(
@project_milestones
){
|
title
,
milestone
|
milestone
.
map
{
|
m
|
m
.
closed_items_count
}.
sum
}
end
def
total_items_count
issue_count
.
merge
(
mr_count
){
|
title
,
issue
,
mr
|
issue
+
mr
}
end
def
percent_complete
percentage_per_milestone
=
{}
closed_items_count
.
map
do
|
title
,
closed_items
|
total_items
=
total_items_count
[
title
]
percentage
=
begin
((
closed_items
*
100
)
/
total_items
).
abs
rescue
ZeroDivisionError
100
end
percentage_per_milestone
.
store
(
title
,
percentage
)
end
percentage_per_milestone
end
end
end
end
...
...
app/views/groups/milestones/index.html.haml
View file @
0723bf1a
%h3
.page-title
%h3
.page-title
Milestones
Milestones
%span
.pull-right
#{
@group_milestones
.
titles
.
count
}
milestones
%span
.pull-right
#{
@group_milestones
.
count
}
milestones
%p
.light
%p
.light
Only milestones from
Only milestones from
...
@@ -21,31 +21,28 @@
...
@@ -21,31 +21,28 @@
%li
%li
.nothing-here-block
No milestones to show
.nothing-here-block
No milestones to show
-
else
-
else
-
@group_milestones
.
titles
.
each
do
|
titl
e
|
-
@group_milestones
.
each
do
|
mileston
e
|
%li
{
class:
"milestone milestone-open"
,
id:
1
}
%li
{
class:
"milestone milestone-open"
,
id:
1
}
.pull-right
.pull-right
=
link_to
root_path
,
class:
"btn btn-small edit-milestone-link btn-grouped"
do
%i
.icon-edit
Edit
=
link_to
'Close Milestone'
,
root_path
,
method: :put
,
remote:
true
,
class:
"btn btn-small btn-remove"
=
link_to
'Close Milestone'
,
root_path
,
method: :put
,
remote:
true
,
class:
"btn btn-small btn-remove"
%h4
%h4
=
link_to_gfm
truncate
(
title
,
length:
100
),
root_path
=
link_to_gfm
truncate
(
milestone
.
title
,
length:
100
),
root_path
-
if
false
-
if
false
%span
.muted
Empty
%span
.muted
Empty
-
else
-
else
%div
%div
%div
%div
=
link_to
root_path
do
=
link_to
root_path
do
=
pluralize
@group_milestones
.
issue_count
[
title
]
,
'Issue'
=
pluralize
milestone
.
issue_count
,
'Issue'
=
link_to
root_path
do
=
link_to
root_path
do
=
pluralize
@group_milestones
.
mr_count
[
title
]
,
'Merge Request'
=
pluralize
milestone
.
merge_requests_count
,
'Merge Request'
%span
.light
#{
@group_milestones
.
percent_complete
[
title
]
}
% complete
%span
.light
#{
milestone
.
percent_complete
}
% complete
.progress.progress-info
.progress.progress-info
.progress-bar
{
style:
"width: #{@group_milestones.percent_complete[title]
}%;"
}
.progress-bar
{
style:
"width: #{milestone.percent_complete
}%;"
}
%div
%div
%br
%br
-
@group_milestones
.
project_names
[
title
]
.
each
do
|
name
|
-
milestone
.
project_names
.
each
do
|
name
|
%span
.label.label-default
%span
.label.label-default
=
name
=
name
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