2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-05 08:59:27 +08:00

FIX: update group user count when bulk adding users

This commit is contained in:
Arpit Jalan 2018-02-23 14:09:49 +05:30
parent 4791b39773
commit 709f201bd4
2 changed files with 17 additions and 0 deletions

View file

@ -534,6 +534,16 @@ class Group < ActiveRecord::Base
if user_attributes.present?
User.where(id: user_ids).update_all(user_attributes)
end
# update group user count
Group.exec_sql <<-SQL.squish
UPDATE groups g
SET user_count =
(SELECT COUNT(gu.user_id)
FROM group_users gu
WHERE gu.group_id = g.id)
WHERE g.id = #{self.id};
SQL
end
if self.grant_trust_level.present?