diff --git a/app/models/project.rb b/app/models/project.rb index c1405a7..4beba83 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -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) } diff --git a/app/models/user.rb b/app/models/user.rb index 30f5aae..cf42d73 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 -- libgit2 0.21.2