zenaight commited on
Commit ·
54f9ee3
1
Parent(s): 762b66d
Refactor transaction_type filtering in search_properties function
Browse files- Updated the search_properties function to replace transaction types 'rent' and 'buy' with 'lease' and 'sale', respectively, for improved clarity and consistency in property search.
- Adjusted the query logic to use equality checks for the new transaction types, ensuring accurate filtering of properties based on user selection.
- Enhanced debug logging to reflect the updated filtering criteria, aiding in troubleshooting and user feedback.
- database.py +8 -8
database.py
CHANGED
|
@@ -331,14 +331,14 @@ async def search_properties(filters: dict) -> list:
|
|
| 331 |
transaction_type = filters.get("transaction_type")
|
| 332 |
if transaction_type:
|
| 333 |
print(f"DEBUG - Filtering by transaction_type: {transaction_type}")
|
| 334 |
-
if transaction_type == "
|
| 335 |
-
# For rent: filter by
|
| 336 |
-
query = query.
|
| 337 |
-
print(f"DEBUG - Filtering for rental properties (
|
| 338 |
-
elif transaction_type == "
|
| 339 |
-
# For buy: filter by sale
|
| 340 |
-
query = query.
|
| 341 |
-
print(f"DEBUG - Filtering for sale properties (sale
|
| 342 |
else:
|
| 343 |
print(f"DEBUG - No transaction_type filter applied")
|
| 344 |
|
|
|
|
| 331 |
transaction_type = filters.get("transaction_type")
|
| 332 |
if transaction_type:
|
| 333 |
print(f"DEBUG - Filtering by transaction_type: {transaction_type}")
|
| 334 |
+
if transaction_type == "lease":
|
| 335 |
+
# For rent: filter by lease price type
|
| 336 |
+
query = query.eq("price_type", "lease")
|
| 337 |
+
print(f"DEBUG - Filtering for rental properties (lease)")
|
| 338 |
+
elif transaction_type == "sale":
|
| 339 |
+
# For buy: filter by sale price type
|
| 340 |
+
query = query.eq("price_type", "sale")
|
| 341 |
+
print(f"DEBUG - Filtering for sale properties (sale)")
|
| 342 |
else:
|
| 343 |
print(f"DEBUG - No transaction_type filter applied")
|
| 344 |
|