Skip to content

Commit

Permalink
feat(server): Add filter for AI-generated descriptions in properties API
Browse files Browse the repository at this point in the history
  • Loading branch information
csulit committed Oct 25, 2024
1 parent dc8c215 commit 2b8a181
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config/deno-kv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 6 additions & 0 deletions server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit 2b8a181

Please sign in to comment.