Commit 5a62d951 authored by Sean McGivern's avatar Sean McGivern

Merge branch '223201-negated-weight-issue-filter-api' into 'master'

Add negated weight issue filter on API

See merge request gitlab-org/gitlab!54867
parents 5b7c554f b280f27a
...@@ -67,7 +67,7 @@ GET /issues?state=opened ...@@ -67,7 +67,7 @@ GET /issues?state=opened
| `milestone` | string | no | The milestone title. `None` lists all issues with no milestone. `Any` lists all issues that have an assigned milestone. | | `milestone` | string | no | The milestone title. `None` lists all issues with no milestone. `Any` lists all issues that have an assigned milestone. |
| `my_reaction_emoji` | string | no | Return issues reacted by the authenticated user by the given `emoji`. `None` returns issues not given a reaction. `Any` returns issues given at least one reaction. _([Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/14016) in GitLab 10.0)_ | | `my_reaction_emoji` | string | no | Return issues reacted by the authenticated user by the given `emoji`. `None` returns issues not given a reaction. `Any` returns issues given at least one reaction. _([Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/14016) in GitLab 10.0)_ |
| `non_archived` | boolean | no | Return issues only from non-archived projects. If `false`, the response returns issues from both archived and non-archived projects. Default is `true`. _(Introduced in [GitLab 13.0](https://gitlab.com/gitlab-org/gitlab/-/issues/197170))_ | | `non_archived` | boolean | no | Return issues only from non-archived projects. If `false`, the response returns issues from both archived and non-archived projects. Default is `true`. _(Introduced in [GitLab 13.0](https://gitlab.com/gitlab-org/gitlab/-/issues/197170))_ |
| `not` | Hash | no | Return issues that do not match the parameters supplied. Accepts: `labels`, `milestone`, `author_id`, `author_username`, `assignee_id`, `assignee_username`, `my_reaction_emoji` | | `not` | Hash | no | Return issues that do not match the parameters supplied. Accepts: `assignee_id`, `assignee_username`, `author_id`, `author_username`, `iids`, `iteration_id`, `iteration_title`, `labels`, `milestone`, and `weight`. |
| `order_by` | string | no | Return issues ordered by `created_at`, `updated_at`, `priority`, `due_date`, `relative_position`, `label_priority`, `milestone_due`, `popularity`, `weight` fields. Default is `created_at` | | `order_by` | string | no | Return issues ordered by `created_at`, `updated_at`, `priority`, `due_date`, `relative_position`, `label_priority`, `milestone_due`, `popularity`, `weight` fields. Default is `created_at` |
| `scope` | string | no | Return issues for the given scope: `created_by_me`, `assigned_to_me` or `all`. Defaults to `created_by_me`<br> For versions before 11.0, use the now deprecated `created-by-me` or `assigned-to-me` scopes instead.<br> _([Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/13004) in GitLab 9.5. [Changed to snake_case](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/18935) in GitLab 11.0)_ | | `scope` | string | no | Return issues for the given scope: `created_by_me`, `assigned_to_me` or `all`. Defaults to `created_by_me`<br> For versions before 11.0, use the now deprecated `created-by-me` or `assigned-to-me` scopes instead.<br> _([Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/13004) in GitLab 9.5. [Changed to snake_case](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/18935) in GitLab 11.0)_ |
| `search` | string | no | Search issues against their `title` and `description` | | `search` | string | no | Search issues against their `title` and `description` |
......
...@@ -16,7 +16,7 @@ module EE ...@@ -16,7 +16,7 @@ module EE
override :negatable_params override :negatable_params
def negatable_params def negatable_params
@negatable_params ||= super + [:iteration_title] @negatable_params ||= super + [:iteration_title, :weight]
end end
end end
......
---
title: Add negated weight issue filtering on API
merge_request: 54867
author:
type: changed
...@@ -15,17 +15,24 @@ module EE ...@@ -15,17 +15,24 @@ module EE
end end
params :negatable_issue_filter_params_ee do params :negatable_issue_filter_params_ee do
optional :weight, type: Integer, desc: 'Return issues without the specified weight'
optional :iteration_id, types: [Integer, String], optional :iteration_id, types: [Integer, String],
integer_or_custom_value: ::Iteration::Predefined::ALL.map { |iteration| iteration.name.downcase }, integer_or_custom_value: ::Iteration::Predefined::ALL.map { |iteration| iteration.name.downcase },
desc: 'Return issues which are assigned to the iteration with the given ID' desc: 'Return issues which are not assigned to the iteration with the given ID'
optional :iteration_title, type: String, optional :iteration_title, type: String,
desc: 'Return issues which are assigned to the iteration with the given title' desc: 'Return issues which are not assigned to the iteration with the given title'
mutually_exclusive :iteration_id, :iteration_title mutually_exclusive :iteration_id, :iteration_title
end end
params :optional_issues_params_ee do params :issues_stats_params_ee do
optional :weight, types: [Integer, String], integer_none_any: true, desc: 'The weight of the issue' optional :weight, types: [Integer, String], integer_none_any: true, desc: 'The weight of the issue'
optional :epic_id, types: [Integer, String], integer_none_any: true, desc: 'The ID of an epic associated with the issues' optional :epic_id, types: [Integer, String], integer_none_any: true, desc: 'The ID of an epic associated with the issues'
optional :iteration_id, types: [Integer, String],
integer_or_custom_value: ::Iteration::Predefined::ALL.map { |iteration| iteration.name.downcase },
desc: 'Return issues which are assigned to the iteration with the given ID'
optional :iteration_title, type: String,
desc: 'Return issues which are assigned to the iteration with the given title'
mutually_exclusive :iteration_id, :iteration_title
end end
end end
......
...@@ -9,6 +9,14 @@ RSpec.describe 'Filter issues weight', :js do ...@@ -9,6 +9,14 @@ RSpec.describe 'Filter issues weight', :js do
let!(:user) { create(:user, name: 'administrator', username: 'root') } let!(:user) { create(:user, name: 'administrator', username: 'root') }
let(:js_dropdown_weight) { '#js-dropdown-weight' } let(:js_dropdown_weight) { '#js-dropdown-weight' }
shared_examples 'filters by negated weight' do
it 'excludes issues with specified weight' do
input_filtered_search(search)
expect_issues_list_count(1)
end
end
def expect_issues_list_count(open_count, closed_count = 0) def expect_issues_list_count(open_count, closed_count = 0)
all_count = open_count + closed_count all_count = open_count + closed_count
...@@ -46,6 +54,20 @@ RSpec.describe 'Filter issues weight', :js do ...@@ -46,6 +54,20 @@ RSpec.describe 'Filter issues weight', :js do
end end
end end
describe 'negated weight only' do
let(:search) { 'weight:!=2' }
it_behaves_like 'filters by negated weight'
context 'when vue_issuables_list is disabled' do
before do
stub_feature_flags(vue_issuables_list: false)
end
it_behaves_like 'filters by negated weight'
end
end
describe 'weight with other filters' do describe 'weight with other filters' do
it 'filters issues by searched weight and text' do it 'filters issues by searched weight and text' do
search = "weight:=2 bug" search = "weight:=2 bug"
......
...@@ -162,6 +162,12 @@ RSpec.describe API::Issues, :mailer do ...@@ -162,6 +162,12 @@ RSpec.describe API::Issues, :mailer do
expect_paginated_array_response([issue3.id, issue2.id, issue1.id]) expect_paginated_array_response([issue3.id, issue2.id, issue1.id])
end end
it 'returns issues without specific weight' do
get api('/issues', user), params: { scope: 'all', not: { weight: 5 } }
expect_paginated_array_response([issue3.id, issue1.id, issue.id])
end
end end
context 'filtering by assignee_username' do context 'filtering by assignee_username' do
......
...@@ -11,10 +11,7 @@ module API ...@@ -11,10 +11,7 @@ module API
params :optional_issue_params_ee do params :optional_issue_params_ee do
end end
params :optional_issues_params_ee do params :issues_stats_params_ee do
end
params :optional_issue_not_params_ee do
end end
def self.update_params_at_least_one_of def self.update_params_at_least_one_of
......
...@@ -15,6 +15,24 @@ module API ...@@ -15,6 +15,24 @@ module API
optional :labels, type: Array[String], coerce_with: ::API::Validations::Types::CommaSeparatedToArray.coerce, desc: 'Comma-separated list of label names' optional :labels, type: Array[String], coerce_with: ::API::Validations::Types::CommaSeparatedToArray.coerce, desc: 'Comma-separated list of label names'
optional :milestone, type: String, desc: 'Milestone title' optional :milestone, type: String, desc: 'Milestone title'
optional :iids, type: Array[Integer], coerce_with: ::API::Validations::Types::CommaSeparatedToIntegerArray.coerce, desc: 'The IID array of issues' optional :iids, type: Array[Integer], coerce_with: ::API::Validations::Types::CommaSeparatedToIntegerArray.coerce, desc: 'The IID array of issues'
optional :author_id, type: Integer, desc: 'Return issues which are not authored by the user with the given ID'
optional :author_username, type: String, desc: 'Return issues which are not authored by the user with the given username'
mutually_exclusive :author_id, :author_username
optional :assignee_id, type: Integer, desc: 'Return issues which are not assigned to the user with the given ID'
optional :assignee_username, type: Array[String], check_assignees_count: true,
coerce_with: Validations::Validators::CheckAssigneesCount.coerce,
desc: 'Return issues which are not assigned to the user with the given username'
mutually_exclusive :assignee_id, :assignee_username
use :negatable_issue_filter_params_ee
end
params :issues_stats_params do
optional :labels, type: Array[String], coerce_with: ::API::Validations::Types::CommaSeparatedToArray.coerce, desc: 'Comma-separated list of label names'
optional :milestone, type: String, desc: 'Milestone title'
optional :iids, type: Array[Integer], coerce_with: ::API::Validations::Types::CommaSeparatedToIntegerArray.coerce, desc: 'The IID array of issues'
optional :search, type: String, desc: 'Search issues for text present in the title, description, or any combination of these' optional :search, type: String, desc: 'Search issues for text present in the title, description, or any combination of these'
optional :in, type: String, desc: '`title`, `description`, or a string joining them with comma' optional :in, type: String, desc: '`title`, `description`, or a string joining them with comma'
...@@ -29,11 +47,6 @@ module API ...@@ -29,11 +47,6 @@ module API
desc: 'Return issues which are assigned to the user with the given username' desc: 'Return issues which are assigned to the user with the given username'
mutually_exclusive :assignee_id, :assignee_username mutually_exclusive :assignee_id, :assignee_username
use :negatable_issue_filter_params_ee
end
params :issues_stats_params do
use :negatable_issue_filter_params
optional :created_after, type: DateTime, desc: 'Return issues created after the specified time' optional :created_after, type: DateTime, desc: 'Return issues created after the specified time'
optional :created_before, type: DateTime, desc: 'Return issues created before the specified time' optional :created_before, type: DateTime, desc: 'Return issues created before the specified time'
optional :updated_after, type: DateTime, desc: 'Return issues updated after the specified time' optional :updated_after, type: DateTime, desc: 'Return issues updated after the specified time'
...@@ -48,7 +61,7 @@ module API ...@@ -48,7 +61,7 @@ module API
optional :my_reaction_emoji, type: String, desc: 'Return issues reacted by the authenticated user by the given emoji' optional :my_reaction_emoji, type: String, desc: 'Return issues reacted by the authenticated user by the given emoji'
optional :confidential, type: Boolean, desc: 'Filter confidential or public issues' optional :confidential, type: Boolean, desc: 'Filter confidential or public issues'
use :optional_issues_params_ee use :issues_stats_params_ee
end end
params :issues_params do params :issues_params do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment