diff options
author | Takuya Noguchi <tak.noguchi.iridge@gmail.com> | 2016-04-22 13:23:21 +0300 |
---|---|---|
committer | Takuya Noguchi <tak.noguchi.iridge@gmail.com> | 2016-05-06 13:57:26 +0300 |
commit | 4ab49fab94284f3f7e3804309ba8825ed28fc24c (patch) | |
tree | ae54ff00e10d3846134189596f66eae9289ce921 /app | |
parent | aa18cc205c90ea027cd3f2788371f36fd0697fda (diff) |
Use outer join for issues ordering by milestones due.
Diffstat (limited to 'app')
-rw-r--r-- | app/models/concerns/issuable.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb index d5166e81474..2e4efc4e8d8 100644 --- a/app/models/concerns/issuable.rb +++ b/app/models/concerns/issuable.rb @@ -35,13 +35,14 @@ module Issuable scope :only_opened, -> { with_state(:opened) } scope :only_reopened, -> { with_state(:reopened) } scope :closed, -> { with_state(:closed) } - scope :order_milestone_due_desc, -> { joins(:milestone).reorder('milestones.due_date DESC, milestones.id DESC') } - scope :order_milestone_due_asc, -> { joins(:milestone).reorder('milestones.due_date ASC, milestones.id ASC') } + scope :order_milestone_due_desc, -> { outer_join_milestone.reorder('milestones.due_date IS NULL ASC, milestones.due_date DESC, milestones.id DESC') } + scope :order_milestone_due_asc, -> { outer_join_milestone.reorder('milestones.due_date IS NULL ASC, milestones.due_date ASC, milestones.id ASC') } scope :without_label, -> { joins("LEFT OUTER JOIN label_links ON label_links.target_type = '#{name}' AND label_links.target_id = #{table_name}.id").where(label_links: { id: nil }) } scope :join_project, -> { joins(:project) } scope :references_project, -> { references(:project) } scope :non_archived, -> { join_project.where(projects: { archived: false }) } + scope :outer_join_milestone, -> { joins("LEFT OUTER JOIN milestones ON milestones.id = #{table_name}.milestone_id") } delegate :name, :email, |