diff options
author | Oswaldo Ferreira <oswaldo@gitlab.com> | 2018-08-06 16:38:37 -0300 |
---|---|---|
committer | Oswaldo Ferreira <oswaldo@gitlab.com> | 2018-08-07 13:02:55 -0300 |
commit | ef66a4a57c8e7591ef5015d594d8bcc4a1077e17 (patch) | |
tree | a5deb711caeb2acad07d05a5a4566aab9848121c /app/models | |
parent | 415b2f943ba80ef3b6746af0a98c6dbe062e803c (diff) | |
download | gitlab-ce-ef66a4a57c8e7591ef5015d594d8bcc4a1077e17.tar.gz |
Fix missing and duplicates on project milestone listing page
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/concerns/issuable.rb | 2 | ||||
-rw-r--r-- | app/models/concerns/sortable.rb | 1 | ||||
-rw-r--r-- | app/models/milestone.rb | 35 |
3 files changed, 21 insertions, 17 deletions
diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb index b93c1145f82..dfdc55b68d1 100644 --- a/app/models/concerns/issuable.rb +++ b/app/models/concerns/issuable.rb @@ -154,7 +154,7 @@ module Issuable end # Break ties with the ID column for pagination - sorted.order(id: :desc) + sorted.with_order_id_desc end def order_due_date_and_labels_priority(excluded_labels: []) diff --git a/app/models/concerns/sortable.rb b/app/models/concerns/sortable.rb index cb76ae971d4..409255fb68b 100644 --- a/app/models/concerns/sortable.rb +++ b/app/models/concerns/sortable.rb @@ -6,6 +6,7 @@ module Sortable extend ActiveSupport::Concern included do + scope :with_order_id_desc, -> { order(id: :desc) } scope :order_id_desc, -> { reorder(id: :desc) } scope :order_id_asc, -> { reorder(id: :asc) } scope :order_created_desc, -> { reorder(created_at: :desc) } diff --git a/app/models/milestone.rb b/app/models/milestone.rb index f2b2d291da9..cb1def1b422 100644 --- a/app/models/milestone.rb +++ b/app/models/milestone.rb @@ -146,22 +146,25 @@ class Milestone < ActiveRecord::Base end def self.sort_by_attribute(method) - case method.to_s - when 'due_date_asc' - reorder(Gitlab::Database.nulls_last_order('due_date', 'ASC')) - when 'due_date_desc' - reorder(Gitlab::Database.nulls_last_order('due_date', 'DESC')) - when 'name_asc' - reorder(Arel::Nodes::Ascending.new(arel_table[:title].lower)) - when 'name_desc' - reorder(Arel::Nodes::Descending.new(arel_table[:title].lower)) - when 'start_date_asc' - reorder(Gitlab::Database.nulls_last_order('start_date', 'ASC')) - when 'start_date_desc' - reorder(Gitlab::Database.nulls_last_order('start_date', 'DESC')) - else - order_by(method) - end + sorted = + case method.to_s + when 'due_date_asc' + reorder(Gitlab::Database.nulls_last_order('due_date', 'ASC')) + when 'due_date_desc' + reorder(Gitlab::Database.nulls_last_order('due_date', 'DESC')) + when 'name_asc' + reorder(Arel::Nodes::Ascending.new(arel_table[:title].lower)) + when 'name_desc' + reorder(Arel::Nodes::Descending.new(arel_table[:title].lower)) + when 'start_date_asc' + reorder(Gitlab::Database.nulls_last_order('start_date', 'ASC')) + when 'start_date_desc' + reorder(Gitlab::Database.nulls_last_order('start_date', 'DESC')) + else + order_by(method) + end + + sorted.with_order_id_desc end ## |