diff --git a/modules/interfaces/interfaceDbChatObjects.py b/modules/interfaces/interfaceDbChatObjects.py index 686eed54..ad9da809 100644 --- a/modules/interfaces/interfaceDbChatObjects.py +++ b/modules/interfaces/interfaceDbChatObjects.py @@ -384,14 +384,12 @@ class ChatObjects: matches = True # Handle general search across text fields - if "search" in filters and filters["search"] is not None: - search_term = str(filters["search"]).strip().lower() + if "search" in filters: + search_term = str(filters["search"]).lower() if search_term: # Search in all string fields found = False for key, value in record.items(): - if value is None: - continue if isinstance(value, str) and search_term in value.lower(): found = True break @@ -406,39 +404,17 @@ class ChatObjects: if field_name == "search": continue # Already handled above - # Skip None or empty filter values (but empty string for strings should still filter) - if filter_value is None: - continue - - # If field doesn't exist in record, reject this record for this filter if field_name not in record: matches = False break record_value = record.get(field_name) - # Handle simple value - default to "contains" for strings, "equals" for other types + # Handle simple value (equals operator) if not isinstance(filter_value, dict): - # Skip None values in record - if record_value is None: + if record_value != filter_value: matches = False break - - # For string fields, default to "contains" for more intuitive filtering - if isinstance(record_value, str) and isinstance(filter_value, str): - # Skip empty filter strings - filter_str = str(filter_value).strip().lower() - if not filter_str: - continue - record_str = record_value.lower() - if filter_str not in record_str: - matches = False - break - else: - # For non-string fields, use exact match - if record_value != filter_value: - matches = False - break continue # Handle filter with operator diff --git a/modules/interfaces/interfaceDbComponentObjects.py b/modules/interfaces/interfaceDbComponentObjects.py index 8deb9682..d3c3c3ed 100644 --- a/modules/interfaces/interfaceDbComponentObjects.py +++ b/modules/interfaces/interfaceDbComponentObjects.py @@ -308,14 +308,12 @@ class ComponentObjects: matches = True # Handle general search across text fields - if "search" in filters and filters["search"] is not None: - search_term = str(filters["search"]).strip().lower() + if "search" in filters: + search_term = str(filters["search"]).lower() if search_term: # Search in all string fields found = False for key, value in record.items(): - if value is None: - continue if isinstance(value, str) and search_term in value.lower(): found = True break @@ -324,72 +322,23 @@ class ComponentObjects: break if not found: matches = False - # Continue checking other filters, but this record won't match # Handle field-specific filters for field_name, filter_value in filters.items(): if field_name == "search": continue # Already handled above - # Skip None or empty filter values (but empty string for strings should still filter) - if filter_value is None: - continue - - # If field doesn't exist in record, reject this record for this filter if field_name not in record: matches = False break record_value = record.get(field_name) - # Handle simple value - default to "contains" for strings, "equals" for other types + # Handle simple value (equals operator) if not isinstance(filter_value, dict): - # Skip None values in record - if record_value is None: + if record_value != filter_value: matches = False break - - # Special handling for fileSize field - parse formatted size strings - if field_name == "fileSize" and isinstance(filter_value, str): - try: - # Parse formatted size string (e.g., "2.13 MB", "1.5 GB", "500 KB") - filter_size_bytes = self._parse_size_string(filter_value) - if filter_size_bytes is not None: - # Compare as integers (bytes) - if isinstance(record_value, (int, float)): - # Allow small tolerance for rounding differences (5% or 50KB, whichever is smaller) - # This accounts for formatting differences but prevents matching very different sizes - tolerance = min(filter_size_bytes * 0.05, 50 * 1024) - if abs(record_value - filter_size_bytes) > tolerance: - matches = False - break - else: - matches = False - break - else: - # If parsing fails, try string contains match - if str(record_value) not in filter_value: - matches = False - break - except Exception: - # If parsing fails, skip this filter - continue - - # For string fields, default to "contains" for more intuitive filtering - elif isinstance(record_value, str) and isinstance(filter_value, str): - # Skip empty filter strings - filter_str = str(filter_value).strip().lower() - if not filter_str: - continue - record_str = record_value.lower() - if filter_str not in record_str: - matches = False - break - else: - # For non-string fields, use exact match - if record_value != filter_value: - matches = False - break continue # Handle filter with operator