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: ed710a7db1228319678037e05ba92647125dda5c043638b81f6df86f837d1bca
4
- data.tar.gz: 988a09163d41afdfed0a2a1a0b9a921966a5dd3764caa79e27e1d45fac8840f7
3
+ metadata.gz: 88b3bd3a9004cfcc3631fb817452cb17cf4b6afc592d16973a9de163b961914a
4
+ data.tar.gz: 4dd8f7071b093f48706371e380a5c17ea59fa4deb51b776817f5d6790255e6f3
5
5
  SHA512:
6
- metadata.gz: 34867c27abc4ccf3ba7401b6709b5d82c5c9dc4b33356c6a50260a79939e05560889277c54715118844fdbe9e1b7bf2bee9fd6a49b866273cda24c5dba078cd6
7
- data.tar.gz: d20fcec984624d11d0690737b3f912fc3ef82189f17c12740b2b01bae7480c8efd83f650fa4376b5f7ecb871727b92ab771e5b88d7527507254d2ed6aff3b046
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"))
@@ -47,7 +47,7 @@ module SnailTrail
47
47
  end
48
48
 
49
49
  def not_creates
50
- where.not(event: "create")
50
+ where.not(event: %w[create batch_create])
51
51
  end
52
52
 
53
53
  def between(start_time, end_time)
@@ -12,7 +12,7 @@ module SnailTrail
12
12
  TINY = 0
13
13
 
14
14
  # Set PRE to nil unless it's a pre-release (beta, rc, etc.)
15
- PRE = 'rc.pre.3'
15
+ PRE = 'rc.pre.4'
16
16
 
17
17
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".").freeze
18
18
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snail_trail
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0.rc.pre.3
4
+ version: 1.1.0.rc.pre.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brands Insurance