Commit 19a0db30 authored by Yorick Peterse's avatar Yorick Peterse

Removed ORDER BY in "of_group" scopes

These scopes don't care about the order. Removing the explicit "ORDER
BY" can speed up the queries by a little bit.
parent 9b0c360b
......@@ -33,7 +33,9 @@ class Issue < ActiveRecord::Base
belongs_to :project
validates :project, presence: true
scope :of_group, ->(group) { where(project_id: group.projects.select(:id)) }
scope :of_group,
->(group) { where(project_id: group.projects.select(:id).reorder(nil)) }
scope :cared, ->(user) { where(assignee_id: user) }
scope :open_for, ->(user) { opened.assigned_to(user) }
......
......@@ -131,7 +131,7 @@ class MergeRequest < ActiveRecord::Base
validate :validate_branches
validate :validate_fork
scope :of_group, ->(group) { where("source_project_id in (:group_project_ids) OR target_project_id in (:group_project_ids)", group_project_ids: group.projects.select(:id)) }
scope :of_group, ->(group) { where("source_project_id in (:group_project_ids) OR target_project_id in (:group_project_ids)", group_project_ids: group.projects.select(:id).reorder(nil)) }
scope :by_branch, ->(branch_name) { where("(source_branch LIKE :branch) OR (target_branch LIKE :branch)", branch: branch_name) }
scope :cared, ->(user) { where('assignee_id = :user OR author_id = :user', user: user.id) }
scope :by_milestone, ->(milestone) { where(milestone_id: milestone) }
......
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