From f845fc68f01bac3074333796df59f77b52a894ff Mon Sep 17 00:00:00 2001 From: casulit Date: Thu, 31 Oct 2024 14:48:05 +0800 Subject: [PATCH] refactor(config): Optimize price_not_shown update logic with ID logging --- config/deno-kv.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/config/deno-kv.ts b/config/deno-kv.ts index 47fa507..f5bee56 100644 --- a/config/deno-kv.ts +++ b/config/deno-kv.ts @@ -207,11 +207,16 @@ export async function listenQueue(kv: Deno.Kv) { const priceNotShown = rawProperty.price_not_shown === "true"; if (priceNotShown) { - await transaction.queryObject({ - args: [rawProperty.full_url, rawProperty.raw_title], - text: - `UPDATE listing SET price_not_shown = TRUE WHERE url = $1 OR title = $2`, + const listingId = await transaction.queryObject<{ id: number }>( + { + args: [rawProperty.full_url, rawProperty.raw_title], + text: + `UPDATE listing SET price_not_shown = TRUE WHERE url = $1 OR title = $2 RETURNING id`, }); + + if (listingId.rowCount && listingId.rowCount > 0) { + console.info("Listing ID:", listingId.rows[0].id); + } } await transaction.queryObject({