Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzenati <zenati@informatique.univ-paris-diderot.fr>2015-06-09 14:28:11 +0300
committerzenati <zenati@informatique.univ-paris-diderot.fr>2015-06-09 14:42:01 +0300
commitb0de6e9ae27a6364819f47d13d827a8aa253c83e (patch)
treea6d647652acd7c6e878cbd246488384f792c251a /app/models
parent9562f028594c6d61834d48f75f8379b0de2ba8ae (diff)
An `in_namespace` scope is already present
Diffstat (limited to 'app/models')
-rw-r--r--app/models/project.rb2
-rw-r--r--app/models/user.rb8
2 files changed, 6 insertions, 4 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 3c9f0dad28b..b161cbe86b9 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -158,7 +158,7 @@ class Project < ActiveRecord::Base
scope :without_user, ->(user) { where('projects.id NOT IN (:ids)', ids: user.authorized_projects.map(&:id) ) }
scope :without_team, ->(team) { team.projects.present? ? where('projects.id NOT IN (:ids)', ids: team.projects.map(&:id)) : scoped }
scope :not_in_group, ->(group) { where('projects.id NOT IN (:ids)', ids: group.project_ids ) }
- scope :in_namespace, ->(namespace) { where(namespace_id: namespace.id) }
+ scope :in_namespace, ->(namespace_ids) { where(namespace_id: namespace_ids) }
scope :in_group_namespace, -> { joins(:group) }
scope :personal, ->(user) { where(namespace_id: user.namespace_id) }
scope :joined, ->(user) { where('namespace_id != ?', user.namespace_id) }
diff --git a/app/models/user.rb b/app/models/user.rb
index 596dc7ea33a..8be0b622704 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -352,9 +352,11 @@ class User < ActiveRecord::Base
end
def owned_projects
- @owned_projects ||= begin
- Project.where(namespace_id: owned_groups.pluck(:id).push(namespace.id)).joins(:namespace)
- end
+ @owned_projects ||=
+ begin
+ namespace_ids = owned_groups.pluck(:id).push(namespace.id)
+ Project.in_namespace(namespace_ids).joins(:namespace)
+ end
end
# Team membership in authorized projects