Commit 19d628dd authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Set default order to authorized_project and authorized_groups

parent c2317d67
......@@ -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) }
......
......@@ -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
......
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