fix: Update query to support multiple tag conditions (#8054)
This commit is contained in:
@@ -35,7 +35,7 @@ class Contacts::FilterService < FilterService
|
|||||||
" (contacts.#{attribute_key})::#{current_filter['data_type']} #{filter_operator_value}#{current_filter['data_type']} #{query_operator} "
|
" (contacts.#{attribute_key})::#{current_filter['data_type']} #{filter_operator_value}#{current_filter['data_type']} #{query_operator} "
|
||||||
when 'standard'
|
when 'standard'
|
||||||
if attribute_key == 'labels'
|
if attribute_key == 'labels'
|
||||||
tag_filter_query('Contact', 'contacts', query_hash, current_index)
|
" #{tag_filter_query('Contact', 'contacts', query_hash, current_index)} "
|
||||||
else
|
else
|
||||||
" LOWER(contacts.#{attribute_key}) #{filter_operator_value} #{query_operator} "
|
" LOWER(contacts.#{attribute_key}) #{filter_operator_value} #{query_operator} "
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class Conversations::FilterService < FilterService
|
|||||||
" (conversations.#{attribute_key})::#{current_filter['data_type']} #{filter_operator_value}#{current_filter['data_type']} #{query_operator} "
|
" (conversations.#{attribute_key})::#{current_filter['data_type']} #{filter_operator_value}#{current_filter['data_type']} #{query_operator} "
|
||||||
when 'standard'
|
when 'standard'
|
||||||
if attribute_key == 'labels'
|
if attribute_key == 'labels'
|
||||||
tag_filter_query('Conversation', 'conversations', query_hash, current_index)
|
" #{tag_filter_query('Conversation', 'conversations', query_hash, current_index)} "
|
||||||
else
|
else
|
||||||
" conversations.#{attribute_key} #{filter_operator_value} #{query_operator} "
|
" conversations.#{attribute_key} #{filter_operator_value} #{query_operator} "
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -140,19 +140,20 @@ describe Conversations::FilterService do
|
|||||||
{
|
{
|
||||||
attribute_key: 'assignee_id',
|
attribute_key: 'assignee_id',
|
||||||
filter_operator: 'equal_to',
|
filter_operator: 'equal_to',
|
||||||
values: [
|
values: [user_1.id, user_2.id],
|
||||||
user_1.id,
|
query_operator: 'AND'
|
||||||
user_2.id
|
|
||||||
],
|
|
||||||
query_operator: 'AND',
|
|
||||||
custom_attribute_type: ''
|
|
||||||
}.with_indifferent_access,
|
}.with_indifferent_access,
|
||||||
{
|
{
|
||||||
attribute_key: 'labels',
|
attribute_key: 'labels',
|
||||||
filter_operator: 'equal_to',
|
filter_operator: 'equal_to',
|
||||||
values: ['support'],
|
values: ['support'],
|
||||||
query_operator: nil,
|
query_operator: 'AND'
|
||||||
custom_attribute_type: ''
|
}.with_indifferent_access,
|
||||||
|
{
|
||||||
|
attribute_key: 'labels',
|
||||||
|
filter_operator: 'not_equal_to',
|
||||||
|
values: ['random-label'],
|
||||||
|
query_operator: nil
|
||||||
}.with_indifferent_access
|
}.with_indifferent_access
|
||||||
]
|
]
|
||||||
result = filter_service.new(params, user_1).perform
|
result = filter_service.new(params, user_1).perform
|
||||||
|
|||||||
Reference in New Issue
Block a user