optimize group invitation code

This commit is contained in:
Arpit Jalan 2018-05-28 17:59:14 +05:30
parent 478ccb6698
commit 8d9c77e113
1 changed files with 1 additions and 1 deletions

View File

@ -139,7 +139,7 @@ class Invite < ActiveRecord::Base
end
else
if topic && topic.category && Guardian.new(invited_by).can_invite_to?(topic)
group_ids = topic.category.groups.pluck(:id) - invite.invited_groups.pluck(:group_id) - Group.where(automatic: true).pluck(:id)
group_ids = topic.category.groups.where(automatic: false).pluck(:id) - invite.invited_groups.pluck(:group_id)
group_ids.each { |group_id| invite.invited_groups.create!(group_id: group_id) }
end
end