Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding social_media value to media type search filter. #2196

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/check_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def initialize(options, file = nil, team_id = Team.current&.id)
@options['esoffset'] ||= 0
adjust_es_window_size

adjust_show_filter
adjust_channel_filter
adjust_numeric_range_filter
adjust_archived_filter
Expand Down Expand Up @@ -429,6 +430,13 @@ def adjust_channel_filter
end
end

def adjust_show_filter
if @options['show'].is_a?(Array) && @options['show'].include?('social_media')
@options['show'].concat(%w[twitter youtube tiktok instagram facebook telegram]).delete('social_media')
@options['show'].uniq!
end
end

def adjust_numeric_range_filter
@options['range_numeric'] = {}
[:linked_items_count, :suggestions_count, :demand, :positive_tipline_search_results_count, :negative_tipline_search_results_count, :tags_as_sentence].each do |field|
Expand Down
5 changes: 5 additions & 0 deletions test/lib/check_search_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,9 @@ def teardown
search = CheckSearch.new({ users: [1, nil] }.to_json, nil, @team.id)
assert_not_nil search.send(:doc_conditions)
end

test "should adjust social media filter" do
search = CheckSearch.new({ show: ['social_media', 'images'] }.to_json, nil, @team.id)
assert_equal ['images', 'twitter', 'youtube', 'tiktok', 'instagram', 'facebook', 'telegram'].sort, search.instance_variable_get('@options')['show'].sort
end
end
Loading