zuora_connect 1.4.23 → 1.4.25

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
  SHA1:
3
- metadata.gz: f166e937a1b966ebbac5f07ac725ddbd56854646
4
- data.tar.gz: 002328d7e34444aa72e5fb2b87831ed4ed51cd88
3
+ metadata.gz: 8f829fdae03f910c8502f0e92526964c38c848bf
4
+ data.tar.gz: ecbc0fc3b85fc1fd3e47dad7c4298e06e8d3d5a1
5
5
  SHA512:
6
- metadata.gz: 85bc2d14075f943e3cc7013ea27a66d2e0e4368e776b5e238d7c82dd38ffa7e7141ada09a9abd25a3829f48f47ea58d051c09ceb5329956e6c1253a695f9eba2
7
- data.tar.gz: 9cb9eb8fa884e14440f822380dbd34144e5ad386dab43779a8bc3ea9aa51d408464826d8df2f6b97de12d80e422a185ff3ab855f73ab832486c9ea7652fe7e09
6
+ metadata.gz: 541161343f45114327362236efb82eadd82b8adc97615abfce4a2842b43bc93b5c7761f9df2aeca5669c6b653b0b49747c09367d9aa2160e0feeb05cf633f000
7
+ data.tar.gz: 8f4221712d631e8cf2ea9f8f64fdbf050f987c8ba0cdee6a2b6a2d68934e8ba5c7f92a598817ae390a1cde3d301ebee029596bebc3ec48e5ffb89630dff9bb41
@@ -208,17 +208,12 @@ module ZuoraConnect
208
208
  Rails.logger.debug("Fetching catalog for default") if entity_id.blank?
209
209
  Rails.logger.debug("Fetching catalog for entity #{entity_id}") if !entity_id.blank?
210
210
  Rails.logger.debug("Fetch Catalog")
211
- if defined?(Redis.current)
212
- Redis.current.keys("Catalog:#{self.id}:*").each do |key|
213
- Redis.current.del(key.to_s)
214
- end
215
- end
216
-
211
+
217
212
  login = zuora_login.client(entity_reference)
218
213
 
219
214
  old_logger = ActiveRecord::Base.logger
220
215
  ActiveRecord::Base.logger = nil
221
- ActiveRecord::Base.connection.execute('UPDATE "public"."zuora_connect_app_instances" SET "catalog" = jsonb_set("catalog", \'{%{entity}}\', \'{}\'), "catalog_mapping" = jsonb_set("catalog_mapping", \'{%{entity}}\', \'{}\') where "id" = %{id}' % {:entity => entity_reference, :id => self.id})
216
+ ActiveRecord::Base.connection.execute('UPDATE "public"."zuora_connect_app_instances" SET "catalog" = jsonb_set("catalog", \'{tmp}\', \'{}\'), "catalog_mapping" = jsonb_set("catalog_mapping", \'{tmp}\', \'{}\') where "id" = %{id}' % {:id => self.id})
222
217
 
223
218
  response = {'nextPage' => login.rest_endpoint("catalog/products?pageSize=#{page_size}")}
224
219
  while !response["nextPage"].blank?
@@ -231,15 +226,15 @@ module ZuoraConnect
231
226
  end
232
227
 
233
228
  output_json["products"].each do |product|
234
- ActiveRecord::Base.connection.execute('UPDATE "public"."zuora_connect_app_instances" SET "catalog_mapping" = jsonb_set("catalog_mapping", \'{%s, %s}\', \'%s\') where "id" = %s' % [entity_reference, product["id"], {"productId" => product["id"]}.to_json.gsub("'", "''"), self.id])
229
+ ActiveRecord::Base.connection.execute('UPDATE "public"."zuora_connect_app_instances" SET "catalog_mapping" = jsonb_set("catalog_mapping", \'{tmp, %s}\', \'%s\') where "id" = %s' % [product["id"], {"productId" => product["id"]}.to_json.gsub("'", "''"), self.id])
235
230
  rateplans = {}
236
231
 
237
232
  product["productRatePlans"].each do |rateplan|
238
- ActiveRecord::Base.connection.execute('UPDATE "public"."zuora_connect_app_instances" SET "catalog_mapping" = jsonb_set("catalog_mapping", \'{%s, %s}\', \'%s\') where "id" = %s' % [entity_reference, rateplan["id"], {"productId" => product["id"], "productRatePlanId" => rateplan["id"]}.to_json.gsub("'", "''"), self.id])
233
+ ActiveRecord::Base.connection.execute('UPDATE "public"."zuora_connect_app_instances" SET "catalog_mapping" = jsonb_set("catalog_mapping", \'{tmp, %s}\', \'%s\') where "id" = %s' % [rateplan["id"], {"productId" => product["id"], "productRatePlanId" => rateplan["id"]}.to_json.gsub("'", "''"), self.id])
239
234
  charges = {}
240
235
 
241
236
  rateplan["productRatePlanCharges"].each do |charge|
242
- ActiveRecord::Base.connection.execute('UPDATE "public"."zuora_connect_app_instances" SET "catalog_mapping" = jsonb_set("catalog_mapping", \'{%s, %s}\', \'%s\') where "id" = %s' % [entity_reference, charge["id"], {"productId" => product["id"], "productRatePlanId" => rateplan["id"], "productRatePlanChargeId" => charge["id"]}.to_json.gsub("'", "''"), self.id])
237
+ ActiveRecord::Base.connection.execute('UPDATE "public"."zuora_connect_app_instances" SET "catalog_mapping" = jsonb_set("catalog_mapping", \'{tmp, %s}\', \'%s\') where "id" = %s' % [charge["id"], {"productId" => product["id"], "productRatePlanId" => rateplan["id"], "productRatePlanChargeId" => charge["id"]}.to_json.gsub("'", "''"), self.id])
243
238
 
244
239
  charges[charge["id"]] = charge.merge({"productId" => product["id"], "productName" => product["name"], "productRatePlanId" => rateplan["id"], "productRatePlanName" => rateplan["name"] })
245
240
  end
@@ -249,9 +244,19 @@ module ZuoraConnect
249
244
  end
250
245
  product["productRatePlans"] = rateplans
251
246
 
252
- ActiveRecord::Base.connection.execute('UPDATE "public"."zuora_connect_app_instances" SET "catalog" = jsonb_set("catalog", \'{%s, %s}\', \'%s\') where "id" = %s' % [entity_reference, product["id"], product.to_json.gsub("'", "''"), self.id])
247
+ ActiveRecord::Base.connection.execute('UPDATE "public"."zuora_connect_app_instances" SET "catalog" = jsonb_set("catalog", \'{tmp, %s}\', \'%s\') where "id" = %s' % [product["id"], product.to_json.gsub("'", "''"), self.id])
248
+ end
249
+ end
250
+
251
+ # Move from tmp to actual
252
+ ActiveRecord::Base.connection.execute('UPDATE "public"."zuora_connect_app_instances" SET "catalog" = jsonb_set("catalog", \'{%{entity}}\', "catalog" #> \'{tmp}\'), "catalog_mapping" = jsonb_set("catalog_mapping", \'{%{entity}}\', "catalog_mapping" #> \'{tmp}\') where "id" = %{id}' % {:entity => entity_reference, :id => self.id})
253
+ if defined?(Redis.current)
254
+ Redis.current.keys("Catalog:#{self.id}:*").each do |key|
255
+ Redis.current.del(key.to_s)
253
256
  end
254
257
  end
258
+ # Clear tmp holder
259
+ ActiveRecord::Base.connection.execute('UPDATE "public"."zuora_connect_app_instances" SET "catalog" = jsonb_set("catalog", \'{tmp}\', \'{}\'), "catalog_mapping" = jsonb_set("catalog_mapping", \'{tmp}\', \'{}\') where "id" = %{id}' % {:id => self.id})
255
260
 
256
261
  ActiveRecord::Base.logger = old_logger
257
262
  self.update_column(:catalog_updated_at, Time.now.utc)
@@ -1,3 +1,3 @@
1
1
  module ZuoraConnect
2
- VERSION = "1.4.23"
3
- end
2
+ VERSION = "1.4.25"
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zuora_connect
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.23
4
+ version: 1.4.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Connect Team