chore: no more 80% match for booking
This commit is contained in:
@@ -358,7 +358,7 @@ class CrossFitBooker:
|
||||
|
||||
def matches_preferred_session(self, session: Dict[str, Any], current_time: datetime) -> bool:
|
||||
"""
|
||||
Check if session matches one of your preferred sessions with fuzzy matching.
|
||||
Check if session matches one of your preferred sessions with exact matching.
|
||||
Args:
|
||||
session (Dict[str, Any]): Session data.
|
||||
current_time (datetime): Current time for comparison.
|
||||
@@ -375,25 +375,12 @@ class CrossFitBooker:
|
||||
session_name: str = session.get("name_activity", "").upper()
|
||||
|
||||
for preferred_day, preferred_time, preferred_name in PREFERRED_SESSIONS:
|
||||
# Exact match first
|
||||
# Exact match
|
||||
if (day_of_week == preferred_day and
|
||||
session_time_str == preferred_time and
|
||||
preferred_name in session_name):
|
||||
return True
|
||||
|
||||
# Fuzzy match fallback (80% similarity)
|
||||
ratio: float = difflib.SequenceMatcher(
|
||||
None,
|
||||
session_name.lower(),
|
||||
preferred_name.lower()
|
||||
).ratio()
|
||||
|
||||
if (day_of_week == preferred_day and
|
||||
abs(session_time.hour - int(preferred_time.split(':')[0])) <= 1 and
|
||||
ratio >= 0.8):
|
||||
logging.debug(f"Fuzzy match: {session_name} → {preferred_name} ({ratio:.2%})")
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user