huginn_acumen_product_agent 1.7.1 → 1.7.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15346dc00cb87c79547be2024b2957762649181385a8863e98159acc7fc7c106
|
4
|
+
data.tar.gz: 18face53f1022e63bb4b554ba60736e00f592775b38909d559f6f5e2c7eea792
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ee1716eb040c991c36911b8d9fc514e6b1084a351ea92f037fb02c46b384b2d9de00c2f51d23b31eff9d98fa597f7e365c13a225f8187da1a8b689dcf385b91
|
7
|
+
data.tar.gz: 6cfc6a2383668400b21de9386207eda46aa01510f17f9471823377bd6763615ecdf7d884f2d3d579c2a5432d6f49d6e931f0e1bcc3c8d93209aac39907e3aeaa
|
@@ -112,6 +112,7 @@ module Agents
|
|
112
112
|
ids = event.payload['ids']
|
113
113
|
products = get_products_by_ids(client, ids)
|
114
114
|
products = get_product_variants(client, products, physical_formats, digital_formats)
|
115
|
+
products = get_master_products_by_id(client, products)
|
115
116
|
products = get_product_categories(client, products)
|
116
117
|
products = get_product_contributors(client, products)
|
117
118
|
|
@@ -71,6 +71,34 @@ module AcumenProductQueryConcern
|
|
71
71
|
products
|
72
72
|
end
|
73
73
|
|
74
|
+
def get_master_products_by_id(client, products)
|
75
|
+
master_products = []
|
76
|
+
|
77
|
+
products.each do |product|
|
78
|
+
wrapper_id = product['identifier']
|
79
|
+
master_id = 0
|
80
|
+
product['model'].each do |variant|
|
81
|
+
if variant['acumenAttributes']['is_master'] && variant['isAvailableForPurchase']
|
82
|
+
master_id = variant['identifier']
|
83
|
+
end
|
84
|
+
end
|
85
|
+
if wrapper_id == master_id || master_id == 0
|
86
|
+
master_products.push(product)
|
87
|
+
else
|
88
|
+
if (master_products.find { |p| p['identifier'] == master_id }).nil?
|
89
|
+
reloaded_product = get_products_by_ids(client, [master_id.to_s])[0]
|
90
|
+
|
91
|
+
unless reloaded_product.nil?
|
92
|
+
reloaded_product['model'] = product['model']
|
93
|
+
master_products.push(reloaded_product)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
master_products
|
100
|
+
end
|
101
|
+
|
74
102
|
def get_product_variants(acumen_client, products, physical_formats, digital_formats)
|
75
103
|
ids = products.map { |product| product['identifier'] }
|
76
104
|
# fetch product/variant relationships
|
@@ -88,24 +116,27 @@ module AcumenProductQueryConcern
|
|
88
116
|
|
89
117
|
def get_product_categories(acumen_client, products)
|
90
118
|
# fetch categories
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
119
|
+
categories_map = {}
|
120
|
+
|
121
|
+
skus = products.map { |product| product['model'].map { |m| m['sku'] } }
|
122
|
+
skus.each do |sku_set|
|
123
|
+
sku_set.each do |sku|
|
124
|
+
response = acumen_client.get_product_categories([sku])
|
125
|
+
categories = process_product_categories_query(response)
|
126
|
+
categories_map[sku] = categories != {} ? categories[sku] : []
|
127
|
+
end
|
128
|
+
end
|
95
129
|
|
96
130
|
# map categories to products
|
97
131
|
products.each do |product|
|
98
132
|
product['model'].each do |variant|
|
99
133
|
variant['categories'] = []
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
'identifier' => category['category_id']
|
107
|
-
})
|
108
|
-
end
|
134
|
+
categories = categories_map[variant['sku']].select { |c| c['inactive'] == '0' }
|
135
|
+
categories.map do |c|
|
136
|
+
variant['categories'].push({
|
137
|
+
'@type' => 'Thing',
|
138
|
+
'identifier' => c['category_id']
|
139
|
+
})
|
109
140
|
end
|
110
141
|
end
|
111
142
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: huginn_acumen_product_agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jacob Spizziri
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|