mirror of
https://github.com/Bunsly/HomeHarvest.git
synced 2026-03-11 07:54:31 -07:00
Add comprehensive filtering system with hour-based datetime and property filters
This major enhancement addresses user needs for more precise filtering and introduces powerful new capabilities for property searches: Key Features: - Hour-based date filtering (past_hours, datetime_from/to with ISO 8601 support) - Server-side property filters (beds, baths, sqft, price, lot_sqft, year_built) - Sorting support (list_date, sold_date, list_price, sqft, beds, baths) - Full timestamp preservation (YYYY-MM-DD HH:MM:SS instead of date-only) - Comprehensive validation with helpful error messages Technical Changes: - Preserve full datetime precision in processors.py and parsers.py - Implement client-side hour-based post-filtering for all listing types - Add server-side GraphQL filters for property characteristics - Generalize filtering to work across SOLD, PENDING, FOR_SALE, FOR_RENT - Add 15 comprehensive tests covering all new features - Maintain full backward compatibility with existing parameters Fixes #113 (sorting support) Version bump to 0.7.0 reflects significant new functionality while maintaining backward compatibility. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -250,9 +250,28 @@ def parse_description(result: dict) -> Description | None:
|
||||
def calculate_days_on_mls(result: dict) -> Optional[int]:
|
||||
"""Calculate days on MLS from result data"""
|
||||
list_date_str = result.get("list_date")
|
||||
list_date = datetime.strptime(list_date_str.split("T")[0], "%Y-%m-%d") if list_date_str else None
|
||||
list_date = None
|
||||
if list_date_str:
|
||||
try:
|
||||
# Parse full datetime, then use date() for day calculation
|
||||
list_date_str_clean = list_date_str.replace('Z', '+00:00') if list_date_str.endswith('Z') else list_date_str
|
||||
list_date = datetime.fromisoformat(list_date_str_clean).replace(tzinfo=None)
|
||||
except (ValueError, AttributeError):
|
||||
# Fallback for date-only format
|
||||
list_date = datetime.strptime(list_date_str.split("T")[0], "%Y-%m-%d") if "T" in list_date_str else None
|
||||
|
||||
last_sold_date_str = result.get("last_sold_date")
|
||||
last_sold_date = datetime.strptime(last_sold_date_str, "%Y-%m-%d") if last_sold_date_str else None
|
||||
last_sold_date = None
|
||||
if last_sold_date_str:
|
||||
try:
|
||||
last_sold_date_str_clean = last_sold_date_str.replace('Z', '+00:00') if last_sold_date_str.endswith('Z') else last_sold_date_str
|
||||
last_sold_date = datetime.fromisoformat(last_sold_date_str_clean).replace(tzinfo=None)
|
||||
except (ValueError, AttributeError):
|
||||
# Fallback for date-only format
|
||||
try:
|
||||
last_sold_date = datetime.strptime(last_sold_date_str, "%Y-%m-%d")
|
||||
except ValueError:
|
||||
last_sold_date = None
|
||||
today = datetime.now()
|
||||
|
||||
if list_date:
|
||||
|
||||
Reference in New Issue
Block a user