iknow_view_models 3.1.3 → 3.1.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: 90ccbf1e2c6cbd490de913f189646e01fbb2b0cda22c6530d9d0794667a6650d
4
- data.tar.gz: 2ed2d34f0d09e4ee4c295a92ef5cf34b0054062ae8dbdc433e33c10840b9e2c5
3
+ metadata.gz: ec9588bf18a627cee4ffefc47ca45c430d733121aa093809cdd366cb8d167d50
4
+ data.tar.gz: 7ff4fe90c65d67251282626bc9ed5d367c6679b879e138fea8cc0b7b32ecfcf0
5
5
  SHA512:
6
- metadata.gz: c3f08635ca1378a44fbd2a9dcade0cf3f8f7edb2169b46f8c1c13c3869d4453f64d5dd96e9f1c91018d466a078ff63d3bce1e892cc938a5a45fe89979f89cacc
7
- data.tar.gz: f02a6f45243e40fb54d7fd0ac146667c6673116b83eb93795b7b454d1ee286bb4d2d797587b9a35662a09f5f3e7ee616b2086aa1a24dc963ade74e22a1e70f92
6
+ metadata.gz: f57f01263cc27d284e31d484f07b56960e5cf743380f912b223e62ceee28dff69fa061f6bdb58c7ac005e5e8b7d0421d8da319ac7debd61160787718f5f77c6e
7
+ data.tar.gz: 76cd1b4f2a14748200b27a704299d7b8a6a610af8e2f32c5517f3d92791793de08257627c1bb6a0ee36785b925ee64af233eab859addc01871ad5165b332ebe3
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IknowViewModels
4
- VERSION = '3.1.3'
4
+ VERSION = '3.1.4'
5
5
  end
@@ -94,11 +94,16 @@ class ViewModel::ActiveRecord
94
94
  # won't yet include through a polymorphic boundary: for now we become
95
95
  # lazy-loading and slow every time that happens.
96
96
 
97
- # Combine our root and referenced updates, and separate by viewmodel type
97
+ # Combine our root and referenced updates, and separate by viewmodel type.
98
+ # Sort by id where possible to obtain as close to possible a deterministic
99
+ # update order to avoid database write deadlocks. This can't be entirely
100
+ # comprehensive, since we can't control the order that shared references
101
+ # are referred to from roots (and therefore visited).
98
102
  updates_by_viewmodel_class =
99
103
  root_updates.lazily
100
104
  .map { |root_update| [nil, root_update] }
101
105
  .concat(referenced_updates)
106
+ .sort_by { |_, update_data| update_data.metadata.id.to_s }
102
107
  .group_by { |_, update_data| update_data.viewmodel_class }
103
108
 
104
109
  # For each viewmodel type, look up referenced models and construct viewmodels to update
@@ -115,7 +120,7 @@ class ViewModel::ActiveRecord
115
120
 
116
121
  if models.size < model_ids.size
117
122
  missing_model_ids = model_ids - models.map(&:id)
118
- missing_viewmodel_refs = missing_model_ids.map { |id| ViewModel::Reference.new(viewmodel_class, id) }
123
+ missing_viewmodel_refs = missing_model_ids.map { |id| ViewModel::Reference.new(viewmodel_class, id) }
119
124
  raise ViewModel::DeserializationError::NotFound.new(missing_viewmodel_refs)
120
125
  end
121
126
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iknow_view_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.3
4
+ version: 3.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - iKnow Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-10 00:00:00.000000000 Z
11
+ date: 2020-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord