Skip to content

Commit

Permalink
feat(server): Add price range filter to properties API endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
csulit committed Oct 30, 2024
1 parent bd80dc3 commit 343d2b2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ app.get("/api/properties", async (c: Context) => {
no_of_bathrooms_max?: string;
no_of_parking_spaces_min?: string;
no_of_parking_spaces_max?: string;
price_min?: string;
price_max?: string;
ai_generated_description?: string;
sort_by?: string;
sort_order?: string;
Expand Down Expand Up @@ -133,6 +135,15 @@ app.get("/api/properties", async (c: Context) => {
);
}

// Add price range condition if both min and max are provided
if (query.price_min && query.price_max) {
addWhereCondition(
`l.price BETWEEN $${paramCounter} AND $${paramCounter + 1}`,
parseFloat(query.price_min),
parseFloat(query.price_max),
);
}

// Add building size range condition if both min and max are provided
if (query.building_size_min && query.building_size_max) {
addWhereCondition(
Expand Down

0 comments on commit 343d2b2

Please sign in to comment.