diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2015-11-18 13:12:44 +0100 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2015-11-18 13:12:44 +0100 |
commit | 26482bddb091a085e2368ff20c3e3e797da74ea3 (patch) | |
tree | c917fa59757d5b2f92424554c4a5b035184d4d73 /app/models | |
parent | 73f302edf98d6c292c048c913f76282058d6d81c (diff) | |
download | gitlab-ce-26482bddb091a085e2368ff20c3e3e797da74ea3.tar.gz |
Don't pluck project IDs in User#owned_projects
This won't work efficiently if you happen to have a lot of projects.
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/user.rb | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 47439ce4b00..9d75bb3aeb4 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -404,10 +404,8 @@ class User < ActiveRecord::Base def owned_projects @owned_projects ||= - begin - namespace_ids = owned_groups.pluck(:id).push(namespace.id) - Project.in_namespace(namespace_ids).joins(:namespace) - end + Project.where('namespace_id IN (?) OR namespace_id = ?', + owned_groups.select(:id), namespace.id).joins(:namespace) end # Team membership in authorized projects |