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
Léo-Paul Géneau
gitlab-ce
Commits
c2426b4e
Commit
c2426b4e
authored
Jan 27, 2017
by
Oswaldo Ferreira
Committed by
Oswaldo Ferreira
Feb 20, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unify issues search behavior by always filtering when ALL labels matches
parent
7c57e099
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
19 deletions
+52
-19
changelogs/unreleased/26315-unify-labels-filter-behavior.yml
changelogs/unreleased/26315-unify-labels-filter-behavior.yml
+4
-0
doc/api/issues.md
doc/api/issues.md
+2
-2
doc/api/v3_to_v4.md
doc/api/v3_to_v4.md
+2
-0
lib/api/issues.rb
lib/api/issues.rb
+3
-11
spec/requests/api/issues_spec.rb
spec/requests/api/issues_spec.rb
+41
-6
No files found.
changelogs/unreleased/26315-unify-labels-filter-behavior.yml
0 → 100644
View file @
c2426b4e
---
title
:
Unify issues search behavior by always filtering when ALL labels matches
merge_request
:
8849
author
:
doc/api/issues.md
View file @
c2426b4e
...
...
@@ -30,7 +30,7 @@ GET /issues?milestone=1.0.0&state=opened
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
|
`state`
| string | no | Return all issues or just those that are
`opened`
or
`closed`
|
|
`labels`
| string | no | Comma-separated list of label names, issues
with any of the labels will
be returned |
|
`labels`
| string | no | Comma-separated list of label names, issues
must have all labels to
be returned |
|
`milestone`
| string| no | The milestone title |
|
`order_by`
| string | no | Return requests ordered by
`created_at`
or
`updated_at`
fields. Default is
`created_at`
|
|
`sort`
| string | no | Return requests sorted in
`asc`
or
`desc`
order. Default is
`desc`
|
...
...
@@ -188,7 +188,7 @@ GET /projects/:id/issues?milestone=1.0.0&state=opened
|
`id`
| integer | yes | The ID of a project |
|
`iid`
| integer | no | Return the issue having the given
`iid`
|
|
`state`
| string | no | Return all issues or just those that are
`opened`
or
`closed`
|
|
`labels`
| string | no | Comma-separated list of label names, issues
with any of the labels will
be returned |
|
`labels`
| string | no | Comma-separated list of label names, issues
must have all labels to
be returned |
|
`milestone`
| string| no | The milestone title |
|
`order_by`
| string | no | Return requests ordered by
`created_at`
or
`updated_at`
fields. Default is
`created_at`
|
|
`sort`
| string | no | Return requests sorted in
`asc`
or
`desc`
order. Default is
`desc`
|
...
...
doc/api/v3_to_v4.md
View file @
c2426b4e
...
...
@@ -27,3 +27,5 @@ changes are in V4:
-
Return pagination headers for all endpoints that return an array
-
Removed
`DELETE projects/:id/deploy_keys/:key_id/disable`
. Use
`DELETE projects/:id/deploy_keys/:key_id`
instead
-
Moved
`PUT /users/:id/(block|unblock)`
to
`POST /users/:id/(block|unblock)`
-
Labels filter on
`projects/:id/issues`
and
`/issues`
now matches only issues containing all labels (i.e.: Logical AND, not OR)
lib/api/issues.rb
View file @
c2426b4e
...
...
@@ -10,17 +10,9 @@ module API
args
.
delete
(
:id
)
args
[
:milestone_title
]
=
args
.
delete
(
:milestone
)
args
[
:label_name
]
=
args
.
delete
(
:labels
)
match_all_labels
=
args
.
delete
(
:match_all_labels
)
labels
=
args
.
delete
(
:labels
)
args
[
:label_name
]
=
labels
if
match_all_labels
issues
=
IssuesFinder
.
new
(
current_user
,
args
).
execute
.
inc_notes_with_associations
# TODO: Remove in 9.0 pass `label_name: args.delete(:labels)` to IssuesFinder
if
!
match_all_labels
&&
labels
.
present?
issues
=
issues
.
includes
(
:labels
).
where
(
'labels.title'
=>
labels
.
split
(
','
))
end
issues
=
IssuesFinder
.
new
(
current_user
,
args
).
execute
issues
.
reorder
(
args
[
:order_by
]
=>
args
[
:sort
])
end
...
...
@@ -77,7 +69,7 @@ module API
get
":id/issues"
do
group
=
find_group!
(
params
[
:id
])
issues
=
find_issues
(
group_id:
group
.
id
,
state:
params
[
:state
]
||
'opened'
,
match_all_labels:
true
)
issues
=
find_issues
(
group_id:
group
.
id
,
state:
params
[
:state
]
||
'opened'
)
present
paginate
(
issues
),
with:
Entities
::
Issue
,
current_user:
current_user
end
...
...
spec/requests/api/issues_spec.rb
View file @
c2426b4e
...
...
@@ -117,14 +117,20 @@ describe API::Issues, api: true do
expect
(
json_response
.
first
[
'labels'
]).
to
eq
([
label
.
title
])
end
it
'returns an array of labeled issues when at least one label matches'
do
get
api
(
"/issues?labels=
#{
label
.
title
}
,foo,bar"
,
user
)
it
'returns an array of labeled issues when all labels matches'
do
label_b
=
create
(
:label
,
title:
'foo'
,
project:
project
)
label_c
=
create
(
:label
,
title:
'bar'
,
project:
project
)
create
(
:label_link
,
label:
label_b
,
target:
issue
)
create
(
:label_link
,
label:
label_c
,
target:
issue
)
get
api
(
"/issues"
,
user
),
labels:
"
#{
label
.
title
}
,
#{
label_b
.
title
}
,
#{
label_c
.
title
}
"
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'labels'
]).
to
eq
([
label
.
title
])
expect
(
json_response
.
first
[
'labels'
]).
to
eq
([
label
_c
.
title
,
label_b
.
title
,
label
.
title
])
end
it
'returns an empty array if no issue matches labels'
do
...
...
@@ -356,6 +362,21 @@ describe API::Issues, api: true do
expect
(
json_response
.
length
).
to
eq
(
0
)
end
it
'returns an array of labeled issues when all labels matches'
do
label_b
=
create
(
:label
,
title:
'foo'
,
project:
group_project
)
label_c
=
create
(
:label
,
title:
'bar'
,
project:
group_project
)
create
(
:label_link
,
label:
label_b
,
target:
group_issue
)
create
(
:label_link
,
label:
label_c
,
target:
group_issue
)
get
api
(
"
#{
base_url
}
"
,
user
),
labels:
"
#{
group_label
.
title
}
,
#{
label_b
.
title
}
,
#{
label_c
.
title
}
"
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'labels'
]).
to
eq
([
label_c
.
title
,
label_b
.
title
,
group_label
.
title
])
end
it
'returns an empty array if no group issue matches labels'
do
get
api
(
"
#{
base_url
}
?labels=foo,bar"
,
user
)
...
...
@@ -549,14 +570,28 @@ describe API::Issues, api: true do
expect
(
json_response
.
first
[
'labels'
]).
to
eq
([
label
.
title
])
end
it
'returns an array of labeled project issues where all labels match'
do
get
api
(
"
#{
base_url
}
/issues?labels=
#{
label
.
title
}
,foo,bar"
,
user
)
it
'returns an array of labeled issues when all labels matches'
do
label_b
=
create
(
:label
,
title:
'foo'
,
project:
project
)
label_c
=
create
(
:label
,
title:
'bar'
,
project:
project
)
create
(
:label_link
,
label:
label_b
,
target:
issue
)
create
(
:label_link
,
label:
label_c
,
target:
issue
)
get
api
(
"
#{
base_url
}
/issues"
,
user
),
labels:
"
#{
label
.
title
}
,
#{
label_b
.
title
}
,
#{
label_c
.
title
}
"
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'labels'
]).
to
eq
([
label
.
title
])
expect
(
json_response
.
first
[
'labels'
]).
to
eq
([
label_c
.
title
,
label_b
.
title
,
label
.
title
])
end
it
'returns an empty array if not all labels matches'
do
get
api
(
"
#{
base_url
}
/issues?labels=
#{
label
.
title
}
,foo"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
0
)
end
it
'returns an empty array if no project issue matches labels'
do
...
...
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