switchman 2.1.2 → 2.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8af8855a0c01eb0bb4b35a8e4efc2e75985ba967e1eec343b8f3b31ccffc3aa2
4
- data.tar.gz: 18f7d47e4ebc386652a39e9d32459caeea44e7fffe2c1751dfebef8b319241e0
3
+ metadata.gz: 62fa2df72b999208e937ba7df468f122159e573d3e838cf86df601592e64fb0c
4
+ data.tar.gz: 20e83c56b8043a8d5e9fbc433db4b1a26a6ec7291389c59463a47ea2ed0b0b87
5
5
  SHA512:
6
- metadata.gz: 9ba8fa917299342a8d4c48048d9bb5454d7d9768a788d32905addffd105f7fffe57b90f977084fcb15c20ff0cdf24adf515d695f839a1bd5c42cd481795d7c0c
7
- data.tar.gz: 3eea73f64b92f8bb826fa4f27b4048ec156b69c0c668386f261f51ee4ffa8b63a554be9d32180cbea3cdd3d066e2ca3801561570534f7a5c25511a8437ee6b93
6
+ metadata.gz: 7c2cdc6f074ddb755b8a80dad67a2828a8f52d2c034f9ec7bdf473d2e2241cf21b80969cc3f6d0dcc33b6713f299ea976370800640a54839d0895cd41c29f01a
7
+ data.tar.gz: 68651c29f71fad57c1e6bbc02b35c6e607a98bc708045841b547c07de4f0ce63048d4a22b22c561d4692a728adc8740fd139ef4d88e5e777cf593e1de679ca9b
@@ -103,8 +103,18 @@ module Switchman
103
103
  def __temp_relative_attribute__
104
104
  raw_value = original_#{attr_name}
105
105
  return nil if raw_value.nil?
106
+
107
+ abs_raw_value = raw_value.abs
106
108
  current_shard = Shard.current(#{shard_category_code_for_reflection(reflection)})
107
- return raw_value if shard == current_shard && raw_value < Shard::IDS_PER_SHARD
109
+ same_shard = shard == current_shard
110
+ return raw_value if same_shard && abs_raw_value < Shard::IDS_PER_SHARD
111
+
112
+ value_shard_id = abs_raw_value / Shard::IDS_PER_SHARD
113
+ # this is a stupid case when someone stuffed a global id for the current shard in instead
114
+ # of a local id
115
+ return raw_value % Shard::IDS_PER_SHARD if value_shard_id == current_shard.id
116
+ return raw_value if !same_shard && abs_raw_value > Shard::IDS_PER_SHARD
117
+ return shard.global_id_for(raw_value) if !same_shard && abs_raw_value < Shard::IDS_PER_SHARD
108
118
 
109
119
  Shard.relative_id_for(raw_value, shard, current_shard)
110
120
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Switchman
4
- VERSION = "2.1.2"
4
+ VERSION = "2.1.3"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: switchman
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Cutrer
8
8
  - James Williams
9
9
  - Jacob Fugal
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
  date: 2021-07-29 00:00:00.000000000 Z
@@ -257,7 +257,7 @@ homepage: http://www.instructure.com/
257
257
  licenses:
258
258
  - MIT
259
259
  metadata: {}
260
- post_install_message:
260
+ post_install_message:
261
261
  rdoc_options: []
262
262
  require_paths:
263
263
  - lib
@@ -272,8 +272,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
272
272
  - !ruby/object:Gem::Version
273
273
  version: '0'
274
274
  requirements: []
275
- rubygems_version: 3.0.3
276
- signing_key:
275
+ rubygems_version: 3.2.24
276
+ signing_key:
277
277
  specification_version: 4
278
278
  summary: Rails sharding magic
279
279
  test_files: []