Skip to content

Commit

Permalink
Fix N+1 query for BotUser query
Browse files Browse the repository at this point in the history
  • Loading branch information
melsawy committed Feb 3, 2025
1 parent 31039ea commit 2fc1965
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/bot/smooch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def self.inherit_status_and_send_report(rid)

# A relationship created by the Smooch Bot or Alegre Bot is related to search results (unless it's a suggestion that was confirmed), so the user has already received the report as a search result... no need to send another report
# Only send a report for (1) Confirmed matches created manually OR (2) Suggestions accepted
created_by_bot = [BotUser.smooch_user&.id, BotUser.alegre_user&.id].include?(relationship.user_id)
created_by_bot = BotUser.where(login: ['alegre', 'smooch'], id: relationship.user_id).exists?
::Bot::Smooch.send_report_from_parent_to_child(parent.id, target.id) if !created_by_bot || relationship.confirmed_by
end
end
Expand Down

0 comments on commit 2fc1965

Please sign in to comment.