Commit 19d628dd239f03e950a41c4498131f9b2a221909

Authored by Dmitriy Zaporozhets
1 parent c2317d67

Set default order to authorized_project and authorized_groups

Showing 2 changed files with 3 additions and 3 deletions   Show diff stats
app/models/project.rb
... ... @@ -100,7 +100,7 @@ class Project < ActiveRecord::Base
100 100 scope :in_team, ->(team) { where("projects.id IN (:ids)", ids: team.projects.map(&:id)) }
101 101 scope :in_namespace, ->(namespace) { where(namespace_id: namespace.id) }
102 102 scope :in_group_namespace, -> { joins(:group) }
103   - scope :sorted_by_activity, -> { order("projects.last_activity_at DESC") }
  103 + scope :sorted_by_activity, -> { reorder("projects.last_activity_at DESC") }
104 104 scope :personal, ->(user) { where(namespace_id: user.namespace_id) }
105 105 scope :joined, ->(user) { where("namespace_id != ?", user.namespace_id) }
106 106 scope :public_only, -> { where(public: true) }
... ...
app/models/user.rb
... ... @@ -231,7 +231,7 @@ class User < ActiveRecord::Base
231 231 def authorized_groups
232 232 @authorized_groups ||= begin
233 233 group_ids = (groups.pluck(:id) + own_groups.pluck(:id) + authorized_projects.pluck(:namespace_id))
234   - Group.where(id: group_ids)
  234 + Group.where(id: group_ids).order('namespaces.name ASC')
235 235 end
236 236 end
237 237  
... ... @@ -240,7 +240,7 @@ class User < ActiveRecord::Base
240 240 def authorized_projects
241 241 @authorized_projects ||= begin
242 242 project_ids = (owned_projects.pluck(:id) + groups_projects.pluck(:id) + projects.pluck(:id)).uniq
243   - Project.where(id: project_ids).includes(:namespace)
  243 + Project.where(id: project_ids).joins(:namespace).order('namespaces.name ASC')
244 244 end
245 245 end
246 246  
... ...