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.

Files changed (1) hide show
  1. 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 == "rent":
335
- # For rent: filter by monthly, weekly, daily price types
336
- query = query.in_("price_type", ["monthly", "weekly", "daily"])
337
- print(f"DEBUG - Filtering for rental properties (monthly, weekly, daily)")
338
- elif transaction_type == "buy":
339
- # For buy: filter by sale, purchase price types
340
- query = query.in_("price_type", ["sale", "purchase", "total"])
341
- print(f"DEBUG - Filtering for sale properties (sale, purchase, total)")
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