Fix: Custom filter distinct select (#3895)

This commit is contained in:
Tejaswini Chile 2022-02-03 14:39:47 +05:30 committed by GitHub
parent 5c6958482f
commit fba7f40bee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -18,7 +18,7 @@ class Contacts::FilterService < FilterService
@query_string += contact_query_string(current_filter, query_hash, current_index)
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
def contact_query_string(current_filter, query_hash, current_index)

View file

@ -55,7 +55,7 @@ describe ::Contacts::FilterService do
attribute_key: 'browser_language',
filter_operator: 'equal_to',
values: ['en'],
query_operator: 'AND'
query_operator: 'OR'
}.with_indifferent_access,
{
attribute_key: 'name',
@ -69,7 +69,7 @@ describe ::Contacts::FilterService do
it 'filter contacts by additional_attributes' do
params[:payload] = payload
result = filter_service.new(params, user_1).perform
expect(result[:contacts].length).to be 1
expect(result[:count]).to be 2
end
it 'filter contact by tags' do