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

Fixing how published fact-checks are filtered for bot preview query. #2199

Merged
merged 1 commit into from
Feb 2, 2025
Merged
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: 2 additions & 6 deletions app/models/team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -577,14 +577,10 @@ def search_for_similar_articles(query, pm = nil, language = nil, settings = nil)
fc_items = []
ex_items = []
threads << Thread.new {
result_ids = Bot::Smooch.search_for_similar_published_fact_checks_no_cache('text', query, [self.id], limit, nil, nil, language, false, settings).map(&:id)
result_ids = Bot::Smooch.search_for_similar_published_fact_checks_no_cache('text', query, [self.id], limit, nil, nil, language, pm.nil?, settings).map(&:id)
unless result_ids.blank?
fc_items = FactCheck.joins(claim_description: :project_media).where('project_medias.id': result_ids)
if pm.nil?
# This means we obtain relevant items for the Bot preview, so we should limit FactChecks to published articles;
# otherwise, relevant articles for ProjectMedia should include all FactChecks.
fc_items = fc_items.where(report_status: 'published')
elsif !pm.fact_check_id.nil?
if !pm&.fact_check_id.nil?
# Exclude the ones already applied to a target item if exists.
fc_items = fc_items.where.not('fact_checks.id' => pm.fact_check_id) unless pm&.fact_check_id.nil?
end
Expand Down
Loading