lib/active_admin/csv_builder.rb in activeadmin-2.11.2 vs lib/active_admin/csv_builder.rb in activeadmin-2.12.0
- old
+ new
@@ -41,11 +41,10 @@
def column(name, options = {}, &block)
@columns << Column.new(name, @resource, column_transitive_options.merge(options), block)
end
def build(controller, csv)
- @collection = controller.send :find_collection, except: :pagination
columns = exec_columns controller.view_context
bom = options[:byte_order_mark]
column_names = options.delete(:column_names) { true }
csv_options = options.except :encoding_options, :humanize_name, :byte_order_mark
@@ -53,17 +52,12 @@
if column_names
csv << CSV.generate_line(columns.map { |c| encode c.name, options }, **csv_options)
end
- ActiveRecord::Base.uncached do
- (1..paginated_collection.total_pages).each do |page|
- paginated_collection(page).each do |resource|
- resource = controller.send :apply_decorator, resource
- csv << CSV.generate_line(build_row(resource, columns, options), **csv_options)
- end
- end
+ controller.send(:in_paginated_batches) do |resource|
+ csv << CSV.generate_line(build_row(resource, columns, options), **csv_options)
end
csv
end
@@ -122,16 +116,8 @@
private
def column_transitive_options
@column_transitive_options ||= @options.slice(*COLUMN_TRANSITIVE_OPTIONS)
- end
-
- def paginated_collection(page_no = 1)
- @collection.public_send(Kaminari.config.page_method_name, page_no).per(batch_size)
- end
-
- def batch_size
- 1000
end
end
end