Commit 893e2410 authored by Pavel Shutsin's avatar Pavel Shutsin

Introduce not filters for code review analytics

Adds support of negative filters for labels
and milestone
parent 33b2c1fc
---
title: Introduce negative filters for code review analytics
merge_request: 30506
author:
type: added
...@@ -21,21 +21,25 @@ module API ...@@ -21,21 +21,25 @@ module API
attempt_project_search_optimizations: true attempt_project_search_optimizations: true
} }
finder_options = params.slice(*MergeRequestsFinder.valid_params).merge(finder_options) MergeRequestsFinder.new(current_user, declared_params.merge(finder_options))
end
MergeRequestsFinder.new(current_user, finder_options)
end end
params :negatable_params do
optional :label_name, type: Array, desc: 'Array of label names to filter by'
optional :milestone_title, type: String, desc: 'Milestone title to filter by'
end end
end end
resource :analytics do resource :analytics do
desc 'List code review information about project' do desc 'List code review information about project'
end
params do params do
requires :project_id, type: Integer, desc: 'Project ID' requires :project_id, type: Integer, desc: 'Project ID'
optional :label_name, type: Array, desc: 'Array of label names to filter by' use :negatable_params
optional :milestone_title, type: String, desc: 'Milestone title to filter by'
use :pagination use :pagination
optional :not, type: Hash do
use :negatable_params
end
end end
get 'code_review' do get 'code_review' do
authorize! :read_code_review_analytics, project authorize! :read_code_review_analytics, project
......
...@@ -54,6 +54,16 @@ describe API::Analytics::CodeReviewAnalytics do ...@@ -54,6 +54,16 @@ describe API::Analytics::CodeReviewAnalytics do
expect(json_response.map { |mr| mr['id']}).to match_array([merge_request_3.id]) expect(json_response.map { |mr| mr['id']}).to match_array([merge_request_3.id])
end end
end end
context 'with negation filters' do
let(:query_params) { super().merge(not: { label_name: [label.title] }) }
it 'applies filter' do
api_call
expect(json_response.map { |mr| mr['id'] }).to match_array([merge_request_1.id])
end
end
end end
context 'when user has no authorization' do context 'when user has no authorization' 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