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 +4 -4
- data/app/models/zuora_connect/app_instance_base.rb +16 -11
- data/lib/zuora_connect/version.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f829fdae03f910c8502f0e92526964c38c848bf
|
4
|
+
data.tar.gz: ecbc0fc3b85fc1fd3e47dad7c4298e06e8d3d5a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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", \'{
|
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", \'{
|
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", \'{
|
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", \'{
|
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", \'{
|
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.
|
3
|
-
end
|
2
|
+
VERSION = "1.4.25"
|
3
|
+
end
|