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
44cff5e8
Commit
44cff5e8
authored
May 12, 2017
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Search for issues with multiple assignees
parent
a240dbab
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
13 deletions
+62
-13
app/finders/issuable_finder.rb
app/finders/issuable_finder.rb
+0
-12
app/finders/issues_finder.rb
app/finders/issues_finder.rb
+20
-1
app/finders/merge_requests_finder.rb
app/finders/merge_requests_finder.rb
+12
-0
spec/finders/issues_finder_spec.rb
spec/finders/issues_finder_spec.rb
+30
-0
No files found.
app/finders/issuable_finder.rb
View file @
44cff5e8
...
...
@@ -309,18 +309,6 @@ class IssuableFinder
params
[
:sort
]
?
items
.
sort
(
params
[
:sort
],
excluded_labels:
label_names
)
:
items
.
reorder
(
id: :desc
)
end
def
by_assignee
(
items
)
if
assignee
items
=
items
.
where
(
assignee_id:
assignee
.
id
)
elsif
no_assignee?
items
=
items
.
where
(
assignee_id:
nil
)
elsif
assignee_id?
||
assignee_username?
# assignee not found
items
=
items
.
none
end
items
end
def
by_author
(
items
)
if
author
items
=
items
.
where
(
author_id:
author
.
id
)
...
...
app/finders/issues_finder.rb
View file @
44cff5e8
...
...
@@ -95,7 +95,13 @@ class IssuesFinder < IssuableFinder
end
def
by_assignee
(
items
)
if
assignee
if
assignees
.
any?
assignees
.
each
do
|
assignee
|
items
=
items
.
assigned_to
(
assignee
)
end
items
elsif
assignee
&&
assignees
.
empty?
items
.
assigned_to
(
assignee
)
elsif
no_assignee?
items
.
unassigned
...
...
@@ -106,6 +112,19 @@ class IssuesFinder < IssuableFinder
end
end
def
assignees
return
@assignees
if
defined?
(
@assignees
)
@assignees
=
if
params
[
:assignee_ids
]
User
.
where
(
id:
params
[
:assignee_ids
])
elsif
params
[
:assignee_usernames
]
User
.
where
(
username:
params
[
:assignee_usernames
])
else
[]
end
end
def
item_project_ids
(
items
)
items
&
.
reorder
(
nil
)
&
.
select
(
:project_id
)
end
...
...
app/finders/merge_requests_finder.rb
View file @
44cff5e8
...
...
@@ -24,6 +24,18 @@ class MergeRequestsFinder < IssuableFinder
private
def
by_assignee
(
items
)
if
assignee
items
=
items
.
where
(
assignee_id:
assignee
.
id
)
elsif
no_assignee?
items
=
items
.
where
(
assignee_id:
nil
)
elsif
assignee_id?
||
assignee_username?
# assignee not found
items
=
items
.
none
end
items
end
def
item_project_ids
(
items
)
items
&
.
reorder
(
nil
)
&
.
select
(
:target_project_id
)
end
...
...
spec/finders/issues_finder_spec.rb
View file @
44cff5e8
...
...
@@ -59,6 +59,36 @@ describe IssuesFinder do
end
end
context
'filtering by assignee IDs'
do
set
(
:user3
)
{
create
(
:user
)
}
let
(
:params
)
{
{
assignee_ids:
[
user2
.
id
,
user3
.
id
]
}
}
before
do
project2
.
team
<<
[
user3
,
:developer
]
issue3
.
assignees
=
[
user2
,
user3
]
end
it
'returns issues assigned to those users'
do
expect
(
issues
).
to
contain_exactly
(
issue3
)
end
end
context
'filtering by assignee usernames'
do
set
(
:user3
)
{
create
(
:user
)
}
let
(
:params
)
{
{
assignee_usernames:
[
user2
.
username
,
user3
.
username
]
}
}
before
do
project2
.
team
<<
[
user3
,
:developer
]
issue3
.
assignees
=
[
user2
,
user3
]
end
it
'returns issues assigned to those users'
do
expect
(
issues
).
to
contain_exactly
(
issue3
)
end
end
context
'filtering by author ID'
do
let
(
:params
)
{
{
author_id:
user2
.
id
}
}
...
...
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