Skip to content

Commit

Permalink
Use .tabular_sort instead of .stable_sort_by
Browse files Browse the repository at this point in the history
`.stable_sort_by` was deprecated here:

ManageIQ/more_core_extensions#76

And will be removed in `more_core_extensions` v4.0, so this is getting
out ahead of that.

Note:  The change to add `.to_a` is ahead of `.tabular_sort` is because
`Ruport::Data::Table` inherits from `Enumerable` and not `Array`, but
`.tabular_sort` was implemented only on `Array`.  Should still work the
same, though.
  • Loading branch information
NickLaMuro committed Feb 4, 2020
1 parent 46dea6c commit 366cbb5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/miq_report_result/result_set_operations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def result_set_for_reporting(report_result, options)
end

result_set.map! { |x| x.slice(*report.col_order) }
result_set = result_set.stable_sort_by(sorting_columns, options[:sort_order])
result_set = result_set.tabular_sort(sorting_columns, options[:sort_order])
result_set = apply_limit_and_offset(result_set, options)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/patches/ruport_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
module Ruport::Data
class Table
def sort_rows_by(col_names = nil, options = {}, &block)
self.class.new(:data => stable_sort_by(col_names, options[:order], &block),
self.class.new(:data => to_a.tabular_sort(col_names, options[:order], &block),
:column_names => @column_names,
:record_class => record_class)
end
Expand Down

0 comments on commit 366cbb5

Please # to comment.