1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { execute_action_and_record } from '../../task_executor.js';
|
||||
import { map_limit, sleep_ms } from '../flow_utils.js';
|
||||
import { sleep_ms } from '../flow_utils.js';
|
||||
import { amazon_product, amazon_search_item, amazon_review } from '../../../models/index.js';
|
||||
import { safe_json_stringify } from '../../json_utils.js';
|
||||
import { close_browser } from '../../puppeteer/puppeteer_runner.js';
|
||||
@@ -51,14 +51,15 @@ async function persist_detail(detail_res_raw) {
|
||||
return;
|
||||
}
|
||||
|
||||
const sku_is_object = detail_res && detail_res.sku && typeof detail_res.sku === 'object' && !Array.isArray(detail_res.sku);
|
||||
|
||||
await amazon_product.upsert({
|
||||
asin,
|
||||
url: detail_res.url || '',
|
||||
title: detail_res.title || null,
|
||||
price: detail_res.price || null,
|
||||
sku: detail_res.sku || null,
|
||||
sku_color: detail_res.sku_color || null,
|
||||
sku_size: detail_res.sku_size || null,
|
||||
sku: sku_is_object ? null : (detail_res.sku || null),
|
||||
sku_json: sku_is_object ? detail_res.sku : null,
|
||||
brand_line: detail_res.brand_line || null,
|
||||
brand_store_url: detail_res.brand_store_url || null,
|
||||
ac_badge: detail_res.ac_badge || null,
|
||||
@@ -69,10 +70,10 @@ async function persist_detail(detail_res_raw) {
|
||||
rating_stars: detail_res.rating_stars || null,
|
||||
review_count_text: detail_res.review_count_text || null,
|
||||
main_image: detail_res.main_image || null,
|
||||
images_json: safe_json_stringify(detail_res.images || []),
|
||||
bullets_json: safe_json_stringify(detail_res.bullets || []),
|
||||
product_info_json: safe_json_stringify(detail_res.product_info || {}),
|
||||
detail_extra_lines_json: safe_json_stringify(detail_res.detail_extra_lines || [])
|
||||
images_json: Array.isArray(detail_res.images) ? detail_res.images : null,
|
||||
bullets_json: Array.isArray(detail_res.bullets) ? detail_res.bullets : null,
|
||||
product_info_json: detail_res.product_info && typeof detail_res.product_info === 'object' ? detail_res.product_info : null,
|
||||
detail_extra_lines_json: Array.isArray(detail_res.detail_extra_lines) ? detail_res.detail_extra_lines : null
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user