Set default order to authorized_project and authorized_groups

This commit is contained in:
Dmitriy Zaporozhets 2013-06-22 13:39:34 +03:00
parent c2317d6785
commit 19d628dd23
2 changed files with 3 additions and 3 deletions

View File

@ -100,7 +100,7 @@ class Project < ActiveRecord::Base
scope :in_team, ->(team) { where("projects.id IN (:ids)", ids: team.projects.map(&:id)) }
scope :in_namespace, ->(namespace) { where(namespace_id: namespace.id) }
scope :in_group_namespace, -> { joins(:group) }
scope :sorted_by_activity, -> { order("projects.last_activity_at DESC") }
scope :sorted_by_activity, -> { reorder("projects.last_activity_at DESC") }
scope :personal, ->(user) { where(namespace_id: user.namespace_id) }
scope :joined, ->(user) { where("namespace_id != ?", user.namespace_id) }
scope :public_only, -> { where(public: true) }

View File

@ -231,7 +231,7 @@ class User < ActiveRecord::Base
def authorized_groups
@authorized_groups ||= begin
group_ids = (groups.pluck(:id) + own_groups.pluck(:id) + authorized_projects.pluck(:namespace_id))
Group.where(id: group_ids)
Group.where(id: group_ids).order('namespaces.name ASC')
end
end
@ -240,7 +240,7 @@ class User < ActiveRecord::Base
def authorized_projects
@authorized_projects ||= begin
project_ids = (owned_projects.pluck(:id) + groups_projects.pluck(:id) + projects.pluck(:id)).uniq
Project.where(id: project_ids).includes(:namespace)
Project.where(id: project_ids).joins(:namespace).order('namespaces.name ASC')
end
end