Project

General

Profile

Defect #23839 » fix_duplicated_order_by_columns_v2.patch

Olivier Houdas, 2016-09-22 14:23

View differences:

app/models/issue_query.rb Thu Sep 15 11:03:45 2016 +0000 → app/models/issue_query.rb Thu Sep 22 14:23:58 2016 +0200
328 328

  
329 329
  # Returns the issues ids
330 330
  def issue_ids(options={})
331
    order_option = [group_by_sort_order, options[:order]].flatten.reject(&:blank?)
331
    # Apply Options sort order in case of duplicated column, if there are group_by sorted columns
332
    if group_by_sort_order
333
      group_by_with_options_sort_order = group_by_sort_order.map { |a| 
334
        i = options[:order].find_index { |b| (b.reverse.split(" ", 2).last == a.reverse.split(" ", 2).last) }
335
        i.nil? ? a : options[:order][i]
336
      }
337
      order_option = [group_by_with_options_sort_order, options[:order]].flatten.reject(&:blank?).uniq
338
    else
339
    order_option = [options[:order]].flatten.reject(&:blank?)
340
    end
332 341

  
333 342
    Issue.visible.
334 343
      joins(:status, :project).
(2-2/2)