Skip to content

Commit

Permalink
CV2-5348: fix n+1 query
Browse files Browse the repository at this point in the history
  • Loading branch information
melsawy committed Oct 16, 2024
1 parent 8309c38 commit da82291
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions app/models/bot/smooch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,12 @@ def report_image
def get_deduplicated_tipline_requests
uids = []
tipline_requests = []
ProjectMedia.where(id: self.related_items_ids).each do |pm|
pm.tipline_requests.find_each do |tr|
uid = tr.tipline_user_uid
next if uids.include?(uid)
uids << uid
tipline_requests << tr
end
pm_ids = ProjectMedia.where(id: self.related_items_ids).map(&:id)
TiplineRequest.where(associated_type: 'ProjectMedia', associated_id: pmids).find_each do |tr|
uid = tr.tipline_user_uid
next if uids.include?(uid)
uids << uid
tipline_requests << tr
end
tipline_requests
end
Expand Down

0 comments on commit da82291

Please sign in to comment.