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
1b3fd278
Commit
1b3fd278
authored
Sep 20, 2018
by
Jarka Košanová
Committed by
Kushal Pandya
Sep 27, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Search epics by state in the finder
- add by_state filter to the epics finder - support count by states
parent
9b1a3088
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
48 additions
and
23 deletions
+48
-23
app/finders/issuable_finder.rb
app/finders/issuable_finder.rb
+5
-1
ee/app/controllers/groups/epics_controller.rb
ee/app/controllers/groups/epics_controller.rb
+1
-1
ee/app/finders/epics_finder.rb
ee/app/finders/epics_finder.rb
+5
-17
ee/changelogs/unreleased/7014-epic-status-tabs.yml
ee/changelogs/unreleased/7014-epic-status-tabs.yml
+5
-0
ee/spec/factories/epics.rb
ee/spec/factories/epics.rb
+9
-0
ee/spec/finders/epics_finder_spec.rb
ee/spec/finders/epics_finder_spec.rb
+23
-4
No files found.
app/finders/issuable_finder.rb
View file @
1b3fd278
...
...
@@ -128,7 +128,7 @@ class IssuableFinder
labels_count
=
1
if
use_cte_for_search?
finder
.
execute
.
reorder
(
nil
).
group
(
:state
).
count
.
each
do
|
key
,
value
|
counts
[
Array
(
key
).
last
.
to_sym
]
+=
value
/
labels_count
counts
[
count_key
(
key
)
]
+=
value
/
labels_count
end
counts
[
:all
]
=
counts
.
values
.
sum
...
...
@@ -297,6 +297,10 @@ class IssuableFinder
klass
.
all
end
def
count_key
(
value
)
Array
(
value
).
last
.
to_sym
end
# rubocop: disable CodeReuse/ActiveRecord
def
by_scope
(
items
)
return
items
.
none
if
current_user_related?
&&
!
current_user
...
...
ee/app/controllers/groups/epics_controller.rb
View file @
1b3fd278
...
...
@@ -101,7 +101,7 @@ class Groups::EpicsController < Groups::ApplicationController
# we need to override the default state which is opened for now because we don't have
# states for epics and need all as default for navigation to work correctly (#4017)
def
set_default_state
params
[
:state
]
=
'
all'
params
[
:state
]
=
'
opened'
if
params
[
:state
].
blank?
end
def
authorize_create_epic!
...
...
ee/app/finders/epics_finder.rb
View file @
1b3fd278
...
...
@@ -11,28 +11,12 @@ class EpicsFinder < IssuableFinder
items
=
by_search
(
items
)
items
=
by_author
(
items
)
items
=
by_timeframe
(
items
)
items
=
by_state
(
items
)
items
=
by_label
(
items
)
sort
(
items
)
end
def
row_count
count
=
execute
.
count
# When filtering by multiple labels, count returns a hash of
# records grouped by id - so we just have to get length of the Hash.
# Once we have state for epics, we can use default issuables row_count
# method.
count
.
is_a?
(
Hash
)
?
count
.
length
:
count
end
# we don't have states for epics for now this method (#4017)
def
count_by_state
{
all:
row_count
}
end
def
group
return
nil
unless
params
[
:group_id
]
return
@group
if
defined?
(
@group
)
...
...
@@ -53,6 +37,10 @@ class EpicsFinder < IssuableFinder
private
def
count_key
(
value
)
Epic
.
states
.
invert
[
Array
(
value
).
last
].
to_sym
end
# rubocop: disable CodeReuse/ActiveRecord
def
groups_user_can_read_epics
(
groups
)
groups
=
Gitlab
::
GroupPlansPreloader
.
new
.
preload
(
groups
)
...
...
ee/changelogs/unreleased/7014-epic-status-tabs.yml
0 → 100644
View file @
1b3fd278
---
title
:
Add Open/Closed epics tabs in list view
merge_request
:
7424
author
:
type
:
added
ee/spec/factories/epics.rb
View file @
1b3fd278
...
...
@@ -13,6 +13,15 @@ FactoryBot.define do
due_date_is_fixed
true
end
trait
:opened
do
state
:opened
end
trait
:closed
do
state
:closed
closed_at
{
Time
.
now
}
end
factory
:labeled_epic
do
transient
do
labels
[]
...
...
ee/spec/finders/epics_finder_spec.rb
View file @
1b3fd278
...
...
@@ -5,10 +5,10 @@ describe EpicsFinder do
let
(
:search_user
)
{
create
(
:user
)
}
let
(
:group
)
{
create
(
:group
,
:private
)
}
let
(
:another_group
)
{
create
(
:group
)
}
let!
(
:epic1
)
{
create
(
:epic
,
group:
group
,
title:
'This is awesome epic'
,
created_at:
1
.
week
.
ago
)
}
let!
(
:epic2
)
{
create
(
:epic
,
group:
group
,
created_at:
4
.
days
.
ago
,
author:
user
,
start_date:
2
.
days
.
ago
,
end_date:
3
.
days
.
from_now
)
}
let!
(
:epic3
)
{
create
(
:epic
,
group:
group
,
description:
'not so awesome'
,
start_date:
5
.
days
.
ago
,
end_date:
3
.
days
.
ago
)
}
let!
(
:epic4
)
{
create
(
:epic
,
group:
another_group
)
}
let!
(
:epic1
)
{
create
(
:epic
,
:opened
,
group:
group
,
title:
'This is awesome epic'
,
created_at:
1
.
week
.
ago
)
}
let!
(
:epic2
)
{
create
(
:epic
,
:opened
,
group:
group
,
created_at:
4
.
days
.
ago
,
author:
user
,
start_date:
2
.
days
.
ago
,
end_date:
3
.
days
.
from_now
)
}
let!
(
:epic3
)
{
create
(
:epic
,
:closed
,
group:
group
,
description:
'not so awesome'
,
start_date:
5
.
days
.
ago
,
end_date:
3
.
days
.
ago
)
}
let!
(
:epic4
)
{
create
(
:epic
,
:closed
,
group:
another_group
)
}
describe
'#execute'
do
def
epics
(
params
=
{})
...
...
@@ -106,6 +106,12 @@ describe EpicsFinder do
end
end
context
'by state'
do
it
'returns all epics with given state'
do
expect
(
epics
(
state: :closed
)).
to
contain_exactly
(
epic3
)
end
end
context
'when subgroups are supported'
,
:nested_groups
do
let
(
:subgroup
)
{
create
(
:group
,
:private
,
parent:
group
)
}
let
(
:subgroup2
)
{
create
(
:group
,
:private
,
parent:
subgroup
)
}
...
...
@@ -184,4 +190,17 @@ describe EpicsFinder do
expect
(
described_class
.
new
(
search_user
,
params
).
row_count
).
to
eq
(
1
)
end
end
describe
'#count_by_state'
do
before
do
group
.
add_developer
(
search_user
)
stub_licensed_features
(
epics:
true
)
end
it
'returns correct counts'
do
results
=
described_class
.
new
(
search_user
,
group_id:
group
.
id
).
count_by_state
expect
(
results
).
to
eq
(
'opened'
=>
2
,
'closed'
=>
1
,
'all'
=>
3
)
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