diff options
author | Ahmad Sherif <me@ahmadsherif.com> | 2016-10-11 15:25:17 +0300 |
---|---|---|
committer | Ahmad Sherif <me@ahmadsherif.com> | 2016-11-18 21:25:45 +0300 |
commit | fd05e26618dd0c123ca476b6f5a3d85f1cfe397a (patch) | |
tree | 39a4ac60382ca7ce8d46e3745ba8a381580d6314 /app/services | |
parent | aea8baed3093c513560e9ac5ac0c5c99508d3001 (diff) |
Precalculate user's authorized projects in database
Closes #23150
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/projects/create_service.rb | 2 | ||||
-rw-r--r-- | app/services/user_project_access_changed_service.rb | 9 |
2 files changed, 11 insertions, 0 deletions
diff --git a/app/services/projects/create_service.rb b/app/services/projects/create_service.rb index 28db145a1f4..159f46cd465 100644 --- a/app/services/projects/create_service.rb +++ b/app/services/projects/create_service.rb @@ -106,6 +106,8 @@ module Projects unless @project.group || @project.gitlab_project_import? @project.team << [current_user, :master, current_user] end + + @project.group.refresh_members_authorized_projects if @project.group end def skip_wiki? diff --git a/app/services/user_project_access_changed_service.rb b/app/services/user_project_access_changed_service.rb new file mode 100644 index 00000000000..2469b4f0d7c --- /dev/null +++ b/app/services/user_project_access_changed_service.rb @@ -0,0 +1,9 @@ +class UserProjectAccessChangedService + def initialize(user_ids) + @user_ids = Array.wrap(user_ids) + end + + def execute + AuthorizedProjectsWorker.bulk_perform_async(@user_ids.map { |id| [id] }) + end +end |