snail_trail 1.1.0.rc.pre.3 → 1.1.0.rc.pre.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88b3bd3a9004cfcc3631fb817452cb17cf4b6afc592d16973a9de163b961914a
|
4
|
+
data.tar.gz: 4dd8f7071b093f48706371e380a5c17ea59fa4deb51b776817f5d6790255e6f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c73ebdb26476bccab3580d78da898272b108531436ca9117d96fbaad9ffa5506e72ea11335c7cde11060293df6071ce7711937ddf4e03b5c51a7e704abc49d8c
|
7
|
+
data.tar.gz: ba9b92445ae869647d453bdf9147357951361234c2accd58663913b0f5b80723bd200015a3580bafafb98d952cf49d5cf5e62079aacf1276f86ead4ae3aa44ab
|
@@ -232,7 +232,7 @@ module SnailTrail
|
|
232
232
|
#
|
233
233
|
# @api private
|
234
234
|
def metadatum_from_model_method(event, method)
|
235
|
-
if event != "create" &&
|
235
|
+
if event != "create" && event != "batch_create" &&
|
236
236
|
@record.has_attribute?(method) &&
|
237
237
|
attribute_changed_in_latest_version?(method)
|
238
238
|
attribute_in_previous_version(method, false)
|
@@ -149,15 +149,23 @@ module SnailTrail
|
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
152
|
+
# When in `performance_mode?`, this will save the `performance_mode_data` array to the "versions" table
|
153
|
+
# In batches of 1_000
|
154
|
+
#
|
155
|
+
# @return [void]
|
156
|
+
#
|
152
157
|
def record_performance_data
|
153
158
|
return unless ::SnailTrail.request.performance_mode?
|
154
159
|
|
155
160
|
all_data = ::SnailTrail.request.performance_mode_data
|
161
|
+
|
156
162
|
first_data = all_data.shift
|
157
163
|
version = @record.class.snail_trail.version_class.create(first_data)
|
158
164
|
update_transaction_id(version)
|
165
|
+
|
159
166
|
all_data.each_slice(1_000) do |datas|
|
160
167
|
timestamp = Time.now.utc.strftime("%Y-%m-%d %H:%M:%S")
|
168
|
+
|
161
169
|
datas.each do |d|
|
162
170
|
add_transaction_id_to(d)
|
163
171
|
d[:created_at] = timestamp
|
@@ -165,10 +173,12 @@ module SnailTrail
|
|
165
173
|
end
|
166
174
|
|
167
175
|
sql = ["INSERT INTO #{version.class.table_name} (#{datas.first.keys.join(", ")}) VALUES"]
|
176
|
+
|
168
177
|
datas.map do |data|
|
169
178
|
values = data.map { |k, v| @record.class.connection.quote(v.is_a?(Hash) ? JSON.generate(v) : v) }
|
170
179
|
sql << "(#{values.join(", ")}),"
|
171
180
|
end
|
181
|
+
|
172
182
|
sql.last.chop!
|
173
183
|
|
174
184
|
@record.class.snail_trail.version_class.connection.execute(sql.join("\n"))
|