rebase again
This commit is contained in:
commit
ce434dd74d
2 changed files with 8 additions and 83 deletions
|
|
@ -384,14 +384,12 @@ class ChatObjects:
|
||||||
matches = True
|
matches = True
|
||||||
|
|
||||||
# Handle general search across text fields
|
# Handle general search across text fields
|
||||||
if "search" in filters and filters["search"] is not None:
|
if "search" in filters:
|
||||||
search_term = str(filters["search"]).strip().lower()
|
search_term = str(filters["search"]).lower()
|
||||||
if search_term:
|
if search_term:
|
||||||
# Search in all string fields
|
# Search in all string fields
|
||||||
found = False
|
found = False
|
||||||
for key, value in record.items():
|
for key, value in record.items():
|
||||||
if value is None:
|
|
||||||
continue
|
|
||||||
if isinstance(value, str) and search_term in value.lower():
|
if isinstance(value, str) and search_term in value.lower():
|
||||||
found = True
|
found = True
|
||||||
break
|
break
|
||||||
|
|
@ -406,39 +404,17 @@ class ChatObjects:
|
||||||
if field_name == "search":
|
if field_name == "search":
|
||||||
continue # Already handled above
|
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:
|
if field_name not in record:
|
||||||
matches = False
|
matches = False
|
||||||
break
|
break
|
||||||
|
|
||||||
record_value = record.get(field_name)
|
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):
|
if not isinstance(filter_value, dict):
|
||||||
# Skip None values in record
|
if record_value != filter_value:
|
||||||
if record_value is None:
|
|
||||||
matches = False
|
matches = False
|
||||||
break
|
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
|
continue
|
||||||
|
|
||||||
# Handle filter with operator
|
# Handle filter with operator
|
||||||
|
|
|
||||||
|
|
@ -308,14 +308,12 @@ class ComponentObjects:
|
||||||
matches = True
|
matches = True
|
||||||
|
|
||||||
# Handle general search across text fields
|
# Handle general search across text fields
|
||||||
if "search" in filters and filters["search"] is not None:
|
if "search" in filters:
|
||||||
search_term = str(filters["search"]).strip().lower()
|
search_term = str(filters["search"]).lower()
|
||||||
if search_term:
|
if search_term:
|
||||||
# Search in all string fields
|
# Search in all string fields
|
||||||
found = False
|
found = False
|
||||||
for key, value in record.items():
|
for key, value in record.items():
|
||||||
if value is None:
|
|
||||||
continue
|
|
||||||
if isinstance(value, str) and search_term in value.lower():
|
if isinstance(value, str) and search_term in value.lower():
|
||||||
found = True
|
found = True
|
||||||
break
|
break
|
||||||
|
|
@ -324,72 +322,23 @@ class ComponentObjects:
|
||||||
break
|
break
|
||||||
if not found:
|
if not found:
|
||||||
matches = False
|
matches = False
|
||||||
# Continue checking other filters, but this record won't match
|
|
||||||
|
|
||||||
# Handle field-specific filters
|
# Handle field-specific filters
|
||||||
for field_name, filter_value in filters.items():
|
for field_name, filter_value in filters.items():
|
||||||
if field_name == "search":
|
if field_name == "search":
|
||||||
continue # Already handled above
|
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:
|
if field_name not in record:
|
||||||
matches = False
|
matches = False
|
||||||
break
|
break
|
||||||
|
|
||||||
record_value = record.get(field_name)
|
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):
|
if not isinstance(filter_value, dict):
|
||||||
# Skip None values in record
|
if record_value != filter_value:
|
||||||
if record_value is None:
|
|
||||||
matches = False
|
matches = False
|
||||||
break
|
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
|
continue
|
||||||
|
|
||||||
# Handle filter with operator
|
# Handle filter with operator
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue