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
909deaa3
Commit
909deaa3
authored
Jul 22, 2016
by
Dan Rowden
Committed by
Alfredo Sumaran
Sep 07, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved milestone counts with a single query
parent
431506bf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
14 deletions
+15
-14
app/helpers/milestones_helper.rb
app/helpers/milestones_helper.rb
+10
-11
app/views/shared/_milestones_filter.html.haml
app/views/shared/_milestones_filter.html.haml
+5
-3
No files found.
app/helpers/milestones_helper.rb
View file @
909deaa3
...
@@ -35,17 +35,16 @@ module MilestonesHelper
...
@@ -35,17 +35,16 @@ module MilestonesHelper
milestone
.
issues
.
with_label
(
label
.
title
).
send
(
state
).
size
milestone
.
issues
.
with_label
(
label
.
title
).
send
(
state
).
size
end
end
def
milestone_count_by_state
(
project
,
state
)
# Returns count of milestones for different states
if
project
.
nil?
# Uses explicit hash keys as the 'opened' state URL params differs from the db value
nil
# and we need to add the total
else
def
milestone_counts
(
project
:)
case
state
counts
=
@project
.
milestones
.
reorder
(
nil
).
group
(
:state
).
count
()
when
'all'
then
@project
.
milestones
.
size
{
when
'closed'
then
@project
.
milestones
.
closed
.
size
'opened'
=>
counts
[
'active'
],
when
'opened'
then
@project
.
milestones
.
active
.
size
'closed'
=>
counts
[
'closed'
],
else
nil
'all'
=>
counts
[
'active'
]
+
counts
[
'closed'
]
end
}
end
end
end
def
milestone_progress_bar
(
milestone
)
def
milestone_progress_bar
(
milestone
)
...
...
app/views/shared/_milestones_filter.html.haml
View file @
909deaa3
-
counts
=
milestone_counts
(
project:
@project
)
%ul
.nav-links
%ul
.nav-links
%li
{
class:
(
"active"
if
params
[
:state
].
blank?
||
params
[
:state
]
==
'opened'
)}
%li
{
class:
(
"active"
if
params
[
:state
].
blank?
||
params
[
:state
]
==
'opened'
)}
=
link_to
milestones_filter_path
(
state:
'opened'
)
do
=
link_to
milestones_filter_path
(
state:
'opened'
)
do
Open
Open
%span
.badge
#{
milestone_count_by_state
(
@project
,
'opened'
)
}
%span
.badge
#{
counts
[
'opened'
]
}
%li
{
class:
(
"active"
if
params
[
:state
]
==
'closed'
)}
%li
{
class:
(
"active"
if
params
[
:state
]
==
'closed'
)}
=
link_to
milestones_filter_path
(
state:
'closed'
)
do
=
link_to
milestones_filter_path
(
state:
'closed'
)
do
Closed
Closed
%span
.badge
#{
milestone_count_by_state
(
@project
,
'closed'
)
}
%span
.badge
#{
counts
[
'closed'
]
}
%li
{
class:
(
"active"
if
params
[
:state
]
==
'all'
)}
%li
{
class:
(
"active"
if
params
[
:state
]
==
'all'
)}
=
link_to
milestones_filter_path
(
state:
'all'
)
do
=
link_to
milestones_filter_path
(
state:
'all'
)
do
All
All
%span
.badge
#{
milestone_count_by_state
(
@project
,
'all'
)
}
%span
.badge
#{
counts
[
'all'
]
}
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