Commit ca7bb439 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'insert-project-authorization-directly-when-creating-project' into 'master'

Speed up project creation for users with many projects

See merge request gitlab-org/gitlab!37070
parents 498b3469 96812901
...@@ -107,12 +107,13 @@ module Projects ...@@ -107,12 +107,13 @@ module Projects
create_readme if @initialize_with_readme create_readme if @initialize_with_readme
end end
# Refresh the current user's authorizations inline (so they can access the # Add an authorization for the current user authorizations inline
# project immediately after this request completes), and any other affected # (so they can access the project immediately after this request
# users in the background # completes), and any other affected users in the background
def setup_authorizations def setup_authorizations
if @project.group if @project.group
current_user.refresh_authorized_projects current_user.project_authorizations.create!(project: @project,
access_level: @project.group.max_member_access_for_user(current_user))
if Feature.enabled?(:specialized_project_authorization_workers) if Feature.enabled?(:specialized_project_authorization_workers)
AuthorizedProjectUpdate::ProjectCreateWorker.perform_async(@project.id) AuthorizedProjectUpdate::ProjectCreateWorker.perform_async(@project.id)
......
---
title: Speed up project creation for users with many projects
merge_request: 37070
author:
type: performance
...@@ -676,10 +676,6 @@ RSpec.describe Projects::CreateService, '#execute' do ...@@ -676,10 +676,6 @@ RSpec.describe Projects::CreateService, '#execute' do
end end
it 'updates authorization for current_user' do it 'updates authorization for current_user' do
expect(Users::RefreshAuthorizedProjectsService).to(
receive(:new).with(user).and_call_original
)
project = create_project(user, opts) project = create_project(user, opts)
expect( expect(
...@@ -711,10 +707,6 @@ RSpec.describe Projects::CreateService, '#execute' do ...@@ -711,10 +707,6 @@ RSpec.describe Projects::CreateService, '#execute' do
end end
it 'updates authorization for current_user' do it 'updates authorization for current_user' do
expect(Users::RefreshAuthorizedProjectsService).to(
receive(:new).with(user).and_call_original
)
project = create_project(user, opts) project = create_project(user, opts)
expect( expect(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment