feat: Store full Dutchie payload in latest_raw_payload

Now stores the complete raw product JSON from Dutchie on every
product refresh. This enables querying any Dutchie field
(terpenes, effects, description, etc.) without schema changes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Kelly
2025-12-13 02:31:00 -07:00
parent 987ed062d5
commit e11400566e

View File

@@ -92,7 +92,7 @@ export async function upsertStoreProducts(
is_on_special, discount_percent, is_on_special, discount_percent,
is_in_stock, stock_status, stock_quantity, total_quantity_available, is_in_stock, stock_status, stock_quantity, total_quantity_available,
thc_percent, cbd_percent, thc_percent, cbd_percent,
image_url, image_url, latest_raw_payload,
first_seen_at, last_seen_at, updated_at first_seen_at, last_seen_at, updated_at
) VALUES ( ) VALUES (
$1, $2, $3, $4, $1, $2, $3, $4,
@@ -101,7 +101,7 @@ export async function upsertStoreProducts(
$13, $14, $13, $14,
$15, $16, $17, $17, $15, $16, $17, $17,
$18, $19, $18, $19,
$20, $20, $21,
NOW(), NOW(), NOW() NOW(), NOW(), NOW()
) )
ON CONFLICT (dispensary_id, provider, provider_product_id) ON CONFLICT (dispensary_id, provider, provider_product_id)
@@ -123,6 +123,7 @@ export async function upsertStoreProducts(
thc_percent = EXCLUDED.thc_percent, thc_percent = EXCLUDED.thc_percent,
cbd_percent = EXCLUDED.cbd_percent, cbd_percent = EXCLUDED.cbd_percent,
image_url = EXCLUDED.image_url, image_url = EXCLUDED.image_url,
latest_raw_payload = EXCLUDED.latest_raw_payload,
last_seen_at = NOW(), last_seen_at = NOW(),
updated_at = NOW() updated_at = NOW()
RETURNING id, (xmax = 0) as is_new, (local_image_path IS NOT NULL) as has_local_image`, RETURNING id, (xmax = 0) as is_new, (local_image_path IS NOT NULL) as has_local_image`,
@@ -148,6 +149,7 @@ export async function upsertStoreProducts(
product.thcPercent !== null && product.thcPercent <= 100 ? product.thcPercent : null, product.thcPercent !== null && product.thcPercent <= 100 ? product.thcPercent : null,
product.cbdPercent !== null && product.cbdPercent <= 100 ? product.cbdPercent : null, product.cbdPercent !== null && product.cbdPercent <= 100 ? product.cbdPercent : null,
product.primaryImageUrl, product.primaryImageUrl,
JSON.stringify(product.rawProduct), // Full Dutchie payload
] ]
); );