Skip to content

Commit

Permalink
Applying comments from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
caiosba committed Aug 1, 2024
1 parent 228a899 commit 6d9154c
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 95 deletions.
6 changes: 4 additions & 2 deletions app/models/team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,8 @@ def filtered_explainers(filters = {})
query = query.where('(title ILIKE ? OR url ILIKE ? OR description ILIKE ?)', *["%#{filters[:text]}%"]*3) if filters[:text].to_s.size > 2

# Exclude the ones already applied to a target item
query = query.where.not(id: ProjectMedia.find(filters[:target_id].to_i).explainer_ids) unless ProjectMedia.find_by_id(filters[:target_id].to_i).nil?
target = ProjectMedia.find_by_id(filters[:target_id].to_i)
query = query.where.not(id: target.explainer_ids) unless target.nil?

query
end
Expand Down Expand Up @@ -537,7 +538,8 @@ def filtered_fact_checks(filters = {})
query = query.where('(fact_checks.title ILIKE ? OR fact_checks.url ILIKE ? OR fact_checks.summary ILIKE ?)', *["%#{filters[:text]}%"]*3) if filters[:text].to_s.size > 2

# Exclude the ones already applied to a target item
query = query.where.not('fact_checks.id' => ProjectMedia.find(filters[:target_id].to_i).fact_check_id) unless ProjectMedia.find_by_id(filters[:target_id].to_i).nil?
target = ProjectMedia.find_by_id(filters[:target_id].to_i)
query = query.where.not('fact_checks.id' => target.fact_check_id) unless target.nil?

query
end
Expand Down
Loading

0 comments on commit 6d9154c

Please sign in to comment.