From 2b8a181a9414fef331159312763e6ca4428b3b4d Mon Sep 17 00:00:00 2001 From: casulit Date: Fri, 25 Oct 2024 10:07:50 +0800 Subject: [PATCH] feat(server): Add filter for AI-generated descriptions in properties API --- config/deno-kv.ts | 2 +- server.ts | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/config/deno-kv.ts b/config/deno-kv.ts index 9e26d09..567fb6a 100644 --- a/config/deno-kv.ts +++ b/config/deno-kv.ts @@ -452,7 +452,7 @@ export async function listenQueue(kv: Deno.Kv) { try { const property = await client_1.queryObject( - `SELECT * FROM Property WHERE ai_generated_description IS NULL AND property_type_id = 1 ORDER BY created_at DESC LIMIT 10` + `SELECT * FROM Property WHERE ai_generated_description IS NULL AND ORDER BY created_at DESC LIMIT 10` ); if (property.rowCount && property.rowCount > 0) { diff --git a/server.ts b/server.ts index 43365c3..0da3f9a 100644 --- a/server.ts +++ b/server.ts @@ -37,6 +37,7 @@ app.get("/api/properties", async (c: Context) => { no_of_bathrooms_max?: string; no_of_parking_spaces_min?: string; no_of_parking_spaces_max?: string; + ai_generated_description?: string; }; if (!query.page) { @@ -178,6 +179,11 @@ app.get("/api/properties", async (c: Context) => { ); } + // Add AI generated description filter if value is 1 + if (query.ai_generated_description === "1") { + addWhereCondition(`p.ai_generated_description IS NOT NULL`); + } + console.log({ sqlWhereClause, sqlParams, nextParamCounter: paramCounter }); const postgres = await client.queryObject({