diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-02-05 14:20:55 -0800 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-02-05 14:20:55 -0800 |
commit | 62ed1c537e9b8aa85d354b377f18083fb71b8e05 (patch) | |
tree | a1b75f804b2e9384190f9d591a2f2701ea8d31db /app/models/user.rb | |
parent | dbca8c97588d1fcc4155b079eb54157991be3aa7 (diff) | |
download | gitlab-ce-62ed1c537e9b8aa85d354b377f18083fb71b8e05.tar.gz |
Explicitly define ordering in models using default_scope
Diffstat (limited to 'app/models/user.rb')
-rw-r--r-- | app/models/user.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 552a37c9533..41c52440320 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -49,6 +49,7 @@ require 'carrierwave/orm/activerecord' require 'file_size_validator' class User < ActiveRecord::Base + include Sortable include Gitlab::ConfigHelper include TokenAuthenticatable extend Gitlab::ConfigHelper @@ -176,7 +177,6 @@ class User < ActiveRecord::Base scope :admins, -> { where(admin: true) } scope :blocked, -> { with_state(:blocked) } scope :active, -> { with_state(:active) } - scope :alphabetically, -> { order('name ASC') } scope :in_team, ->(team){ where(id: team.member_ids) } scope :not_in_team, ->(team){ where('users.id NOT IN (:ids)', ids: team.member_ids) } scope :not_in_project, ->(project) { project.users.present? ? where("id not in (:ids)", ids: project.users.map(&:id) ) : all } @@ -290,7 +290,7 @@ class User < ActiveRecord::Base def authorized_groups @authorized_groups ||= begin group_ids = (groups.pluck(:id) + authorized_projects.pluck(:namespace_id)) - Group.where(id: group_ids).order('namespaces.name ASC') + Group.where(id: group_ids) end end @@ -301,7 +301,7 @@ class User < ActiveRecord::Base project_ids = personal_projects.pluck(:id) project_ids.push(*groups_projects.pluck(:id)) project_ids.push(*projects.pluck(:id).uniq) - Project.where(id: project_ids).joins(:namespace).order('namespaces.name ASC') + Project.where(id: project_ids) end end |