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
iv
gitlab-ce
Commits
58570880
Commit
58570880
authored
Jun 25, 2014
by
Marin Jankovski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create group milestones service.
parent
e1afea77
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
97 additions
and
3 deletions
+97
-3
app/controllers/groups/milestones_controller.rb
app/controllers/groups/milestones_controller.rb
+2
-0
app/services/milestones/group_service.rb
app/services/milestones/group_service.rb
+73
-0
app/views/groups/milestones/index.html.haml
app/views/groups/milestones/index.html.haml
+22
-3
No files found.
app/controllers/groups/milestones_controller.rb
View file @
58570880
...
...
@@ -6,5 +6,7 @@ class Groups::MilestonesController < ApplicationController
project_ids
=
@group
.
projects
project_milestones
=
Milestone
.
where
(
project_id:
project_ids
)
@milestones
=
project_milestones
@group_milestones
=
Milestones
::
GroupService
.
new
(
@group
,
current_user
,
project_milestones
)
end
end
app/services/milestones/group_service.rb
0 → 100644
View file @
58570880
module
Milestones
class
GroupService
<
Milestones
::
BaseService
def
initialize
(
group
,
user
,
project_milestones
)
@group
=
group
@user
=
user
@project_milestones
=
project_milestones
.
group_by
(
&
:title
)
end
def
titles
@project_milestones
.
map
{
|
title
,
milestone
|
title
}
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
open_issues_count
.
merge
(
open_mr_count
){
|
title
,
issue
,
mr
|
issue
+
mr
}
end
def
closed_items_count
closed_issues_count
.
merge
(
close_mr_count
){
|
title
,
issue
,
mr
|
issue
+
mr
}
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
app/views/groups/milestones/index.html.haml
View file @
58570880
...
...
@@ -17,11 +17,11 @@
.col-md-9
.panel.panel-default
%ul
.well-list
-
if
@milestones
.
blank?
-
if
@
group_
milestones
.
blank?
%li
.nothing-here-block
No milestones to show
-
else
-
@
milestones
.
group_by
(
&
:title
).
each
do
|
mileston
e
|
-
@
group_milestones
.
titles
.
each
do
|
titl
e
|
%li
{
class:
"milestone milestone-open"
,
id:
1
}
.pull-right
=
link_to
root_path
,
class:
"btn btn-small edit-milestone-link btn-grouped"
do
...
...
@@ -29,4 +29,23 @@
Edit
=
link_to
'Close Milestone'
,
root_path
,
method: :put
,
remote:
true
,
class:
"btn btn-small btn-remove"
%h4
=
link_to_gfm
truncate
(
milestone
.
first
,
length:
100
),
root_path
=
link_to_gfm
truncate
(
title
,
length:
100
),
root_path
-
if
false
%span
.muted
Empty
-
else
%div
%div
=
link_to
root_path
do
=
pluralize
@group_milestones
.
issue_count
[
title
],
'Issue'
=
link_to
root_path
do
=
pluralize
@group_milestones
.
mr_count
[
title
],
'Merge Request'
%span
.light
#{
@group_milestones
.
percent_complete
[
title
]
}
% complete
.progress.progress-info
.progress-bar
{
style:
"width: #{@group_milestones.percent_complete[title]}%;"
}
%div
%br
-
@group_milestones
.
project_names
[
title
].
each
do
|
name
|
%span
.label.label-default
=
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