diff options
author | Ahmad Sherif <me@ahmadsherif.com> | 2016-10-11 14:25:17 +0200 |
---|---|---|
committer | Ahmad Sherif <me@ahmadsherif.com> | 2016-11-18 20:25:45 +0200 |
commit | fd05e26618dd0c123ca476b6f5a3d85f1cfe397a (patch) | |
tree | 39a4ac60382ca7ce8d46e3745ba8a381580d6314 /app/models/member.rb | |
parent | aea8baed3093c513560e9ac5ac0c5c99508d3001 (diff) | |
download | gitlab-ce-fd05e26618dd0c123ca476b6f5a3d85f1cfe397a.tar.gz |
Precalculate user's authorized projects in database
Closes #23150
Diffstat (limited to 'app/models/member.rb')
-rw-r--r-- | app/models/member.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/app/models/member.rb b/app/models/member.rb index b89ba8ecbb8..7be2665bf48 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -113,6 +113,8 @@ class Member < ActiveRecord::Base member.save end + UserProjectAccessChangedService.new(user.id).execute if user.is_a?(User) + member end @@ -239,6 +241,7 @@ class Member < ActiveRecord::Base end def post_create_hook + UserProjectAccessChangedService.new(user.id).execute system_hook_service.execute_hooks_for(self, :create) end @@ -247,9 +250,19 @@ class Member < ActiveRecord::Base end def post_destroy_hook + refresh_member_authorized_projects system_hook_service.execute_hooks_for(self, :destroy) end + def refresh_member_authorized_projects + # If user/source is being destroyed, project access are gonna be destroyed eventually + # because of DB foreign keys, so we shouldn't bother with refreshing after each + # member is destroyed through association + return if destroyed_by_association.present? + + UserProjectAccessChangedService.new(user_id).execute + end + def after_accept_invite post_create_hook end |