Skip to content

Commit

Permalink
CV2-5628: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
melsawy committed Nov 14, 2024
1 parent ddeb38d commit b675248
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/check_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,11 @@ def medias_query
else
and_conditions.concat(custom_conditions)
end
# Build ES query using this format: `bool: { must: [{and_conditions}], should: [{or_conditions}, must_not: [{not_conditions}]] }`
query = {}
query[:must] = and_conditions unless and_conditions.blank?
query[:should] = or_conditions unless or_conditions.blank?
query[:must_not] = not_conditions unless not_conditions.blank?
{ must: and_conditions, should: or_conditions, must_not: not_conditions }.each do |k, v|
query[k] = v unless v.blank?
end
{ bool: query }
end

Expand Down Expand Up @@ -756,12 +757,12 @@ def hit_es_for_range_filter
def build_feed_conditions
return [] unless feed_query?
conditions = []
feed_options = @options.clone
feed_options.delete('feed_id')
feed_options[:show_similar] = !!@options['show_similar']
@feed.get_team_filters(@options['feed_team_ids']).each do |filters|
team_id = filters['team_id'].to_i
feed_options = @options.clone
feed_options.delete('feed_id')
filters.merge!(feed_options)
conditions << CheckSearch.new(filters.merge({ show_similar: !!@options['show_similar'] }).to_json, nil, team_id).medias_query
conditions << CheckSearch.new(filters.merge(feed_options).to_json, nil, team_id).medias_query
end
conditions
end
Expand Down

0 comments on commit b675248

Please sign in to comment.