active_report 5.2.6 → 5.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_report/record.rb +15 -9
- data/lib/active_report/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8bde1de5a7f2f2eea8844b30fd811eb3bde0026344bd5c83386995ac0f40d6a8
|
4
|
+
data.tar.gz: 0624ceb3f8ded798a662f235eab1050c26ad4fab3ceac2e01d19f44dbdcf2cab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a314a3fd29f83176b240c40c4a0f9c246c34d849e67dd557a3bec6d33d715377b1ed9a5f59b104b4cf5edbc031c76128d43e1207908995d154a9f5e224302c3f
|
7
|
+
data.tar.gz: 2799ed6b5c9e652f9a17b491cbacf1a8f132de1672017cbf120372eed28d799c9333a896e695b591e2174f4d38a0ad8e0255169442572fb334cf81d775f35acf
|
data/lib/active_report/record.rb
CHANGED
@@ -54,29 +54,35 @@ class ActiveReport::Record < ActiveReport::Base
|
|
54
54
|
private
|
55
55
|
|
56
56
|
def export_csv
|
57
|
+
@data = @data.result if @data.is_a?(Ransack::Search)
|
58
|
+
|
57
59
|
CSV.generate(@opts[:options]) do |csv|
|
58
60
|
csv << @opts[:headers]
|
59
|
-
|
60
|
-
@data.find_each(start: @opts[:start],
|
61
|
-
finish: @opts[:finish],
|
62
|
-
batch_size: @opts[:batch_size],
|
63
|
-
error_on_ignore: @opts[:error_on_ignore]) do |row|
|
61
|
+
@data.find_each(find_each_options) do |row|
|
64
62
|
csv << filter_values(row.attributes)
|
65
63
|
end
|
66
64
|
end
|
67
65
|
end
|
68
66
|
|
69
67
|
def export_stream
|
68
|
+
@data = @data.result if @data.is_a?(Ransack::Search)
|
69
|
+
|
70
70
|
Enumerator.new do |csv|
|
71
71
|
csv << CSV.generate_line(@opts[:headers])
|
72
72
|
|
73
|
-
@data.find_each(
|
74
|
-
finish: @opts[:finish],
|
75
|
-
batch_size: @opts[:batch_size],
|
76
|
-
error_on_ignore: @opts[:error_on_ignore]) do |row|
|
73
|
+
@data.find_each(find_each_options) do |row|
|
77
74
|
csv << CSV.generate_line(filter_values(row.attributes))
|
78
75
|
end
|
79
76
|
end
|
80
77
|
end
|
81
78
|
|
79
|
+
def find_each_options
|
80
|
+
{
|
81
|
+
start: @opts[:start],
|
82
|
+
finish: @opts[:finish],
|
83
|
+
batch_size: @opts[:batch_size],
|
84
|
+
error_on_ignore: @opts[:error_on_ignore]
|
85
|
+
}
|
86
|
+
end
|
87
|
+
|
82
88
|
end
|