zuora_connect 2.0.60h → 2.0.60i

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: f42f8d9aa43845b520355af09e97e78350733a04f0585aeb04fafc7f5ed6a1d6
4
- data.tar.gz: 7dfd646a3fa29e7ddbc57ecc461c9d0789a44fecd9eca7a17bdde0e8e037396b
3
+ metadata.gz: 1fc4afe6a78f90d6c87cfa73da32a7b129a5e584672886cad408368694aad1aa
4
+ data.tar.gz: bdfcffca2d8ec4eb224408b25c6b14248bde1623265cca5be7a6e46ea2c63931
5
5
  SHA512:
6
- metadata.gz: 504efdf52062062981373b857b4ff520473e065a4b9d59f1b4282e4c10de2f06285ba2a80790d810362ad62b011d5ffba7f0fb3235e40fc94b629ea59eff2119
7
- data.tar.gz: 210ed53a545c3b86beaf0d7dfa08d567f53b88d0f2d711008bf73b15ebb14b38cdb2c310d4dd9cac891364877856c0b9e9b232bd39838fca5a786f896db6ccbb
6
+ metadata.gz: 45fbd12da62db03d87bfb2879efe01a531bb23560785145d296b68e5d06d97dbd31d6e382f2c7f53d48267a91bbaf64ca907c10d0d009c1e21bd1b13ca442acc
7
+ data.tar.gz: 433893af604861265c826253fb5d40236f1662ef78506bac6c87d82c315552a42297668f393c73b32e7bcdb8ce501a33ae0fc0b48dd9dff95fb43ad61c16fde2
@@ -1,9 +1,15 @@
1
1
  module ActiveRecord
2
2
  module ConnectionAdapters
3
3
  class PostgreSQLAdapter < AbstractAdapter
4
+
5
+ SCHEMA_ADDITIONAL_TYPES = 'SchemaAdditionalTypes'.freeze
6
+
4
7
  private
5
8
  def load_additional_types_latest(oids = nil)
6
9
  initializer = OID::TypeMapInitializer.new(type_map)
10
+
11
+ return if loaded_from_cache?(initializer)
12
+
7
13
  if supports_ranges?
8
14
  query = <<-SQL
9
15
  SELECT DISTINCT on (t.typname) t.oid, t.typname, t.typelem, t.typdelim, t.typinput, r.rngsubtype, t.typtype, t.typbasetype
@@ -20,16 +26,20 @@ module ActiveRecord
20
26
  if oids
21
27
  query += "WHERE t.oid::integer IN (%s)" % oids.join(", ")
22
28
  else
23
- query += initializer.query_conditions_for_initial_load
29
+ query += initializer.query_conditions_for_initial_load(type_map)
24
30
  end
25
31
 
26
32
  execute_and_clear(query, "SCHEMA", []) do |records|
33
+ cache_additional_types(records)
27
34
  initializer.run(records)
28
35
  end
29
36
  end
30
37
 
31
38
  def load_additional_types_deprecated(type_map, oids = nil)
32
39
  initializer = OID::TypeMapInitializer.new(type_map)
40
+
41
+ return if loaded_from_cache?(initializer)
42
+
33
43
  if supports_ranges?
34
44
  query = <<-SQL
35
45
  SELECT DISTINCT on (t.typname) t.oid, t.typname, t.typelem, t.typdelim, t.typinput, r.rngsubtype, t.typtype, t.typbasetype
@@ -50,10 +60,37 @@ module ActiveRecord
50
60
  end
51
61
 
52
62
  execute_and_clear(query, "SCHEMA", []) do |records|
63
+ cache_additional_types(records)
53
64
  initializer.run(records)
54
65
  end
55
66
  end
56
67
 
68
+ def loaded_from_cache?(initializer)
69
+ if defined?(Redis.current)
70
+ begin
71
+ if Redis.current.exists(SCHEMA_ADDITIONAL_TYPES)
72
+ initializer.run(JSON.parse(Redis.current.get(SCHEMA_ADDITIONAL_TYPES)))
73
+ return true
74
+ end
75
+ rescue => ex
76
+ Rails.logger.warn('Exception occurred while loading additional types', ex)
77
+ end
78
+ end
79
+
80
+ false
81
+ end
82
+
83
+ def cache_additional_types(records)
84
+ if defined?(Redis.current)
85
+ begin
86
+ Redis.current.setex(SCHEMA_ADDITIONAL_TYPES, 1.hour.to_i, records.to_json)
87
+ rescue => ex
88
+ Rails.logger.warn('Exception occurred while caching additional types', ex)
89
+ end
90
+ end
91
+ end
92
+
93
+
57
94
  rails_version = Rails.version.split('.').map { |x| x.to_i }
58
95
  if (rails_version <=> [5, 2, 0]) >= 1
59
96
  alias :load_additional_types :load_additional_types_latest
@@ -1,3 +1,3 @@
1
1
  module ZuoraConnect
2
- VERSION = "2.0.60h"
2
+ VERSION = "2.0.60i"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zuora_connect
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.60h
4
+ version: 2.0.60i
5
5
  platform: ruby
6
6
  authors:
7
7
  - Connect Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-19 00:00:00.000000000 Z
11
+ date: 2020-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: apartment