Fix: Custom filter distinct select (#3895)
This commit is contained in:
@@ -18,7 +18,7 @@ class Contacts::FilterService < FilterService
|
|||||||
@query_string += contact_query_string(current_filter, query_hash, current_index)
|
@query_string += contact_query_string(current_filter, query_hash, current_index)
|
||||||
end
|
end
|
||||||
|
|
||||||
base_relation.select('distinct contacts.id').where(@query_string, @filter_values.with_indifferent_access)
|
base_relation.where(@query_string, @filter_values.with_indifferent_access)
|
||||||
end
|
end
|
||||||
|
|
||||||
def contact_query_string(current_filter, query_hash, current_index)
|
def contact_query_string(current_filter, query_hash, current_index)
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ describe ::Contacts::FilterService do
|
|||||||
attribute_key: 'browser_language',
|
attribute_key: 'browser_language',
|
||||||
filter_operator: 'equal_to',
|
filter_operator: 'equal_to',
|
||||||
values: ['en'],
|
values: ['en'],
|
||||||
query_operator: 'AND'
|
query_operator: 'OR'
|
||||||
}.with_indifferent_access,
|
}.with_indifferent_access,
|
||||||
{
|
{
|
||||||
attribute_key: 'name',
|
attribute_key: 'name',
|
||||||
@@ -69,7 +69,7 @@ describe ::Contacts::FilterService do
|
|||||||
it 'filter contacts by additional_attributes' do
|
it 'filter contacts by additional_attributes' do
|
||||||
params[:payload] = payload
|
params[:payload] = payload
|
||||||
result = filter_service.new(params, user_1).perform
|
result = filter_service.new(params, user_1).perform
|
||||||
expect(result[:contacts].length).to be 1
|
expect(result[:count]).to be 2
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'filter contact by tags' do
|
it 'filter contact by tags' do
|
||||||
|
|||||||
Reference in New Issue
Block a user