Improve segment filters for custom data fields - #550
Open
pausan wants to merge 1 commit into
Open
Conversation
- Exposed custom data filters to the UI. - Query filter improvements to performs more consistent comparisons by taking into account field types instead of failing silently. - Added more tests for custom fields.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Segment filters on custom data (data.*) previously only offered matches, is empty and is not empty in the editor, even though the query layer supported more. This PR exposes the richer set and makes comparisons behave predictably.
UI (segment editor)
New operators for custom fields: starts with, ends with, includes, is greater than, is smaller than, is after date, is before date.
The value input adapts to the operator (text, number, or the existing date/time/timezone picker), and existing filters are correctly round-tripped back into the editor.
Query layer (Keila.Contacts.Query)
$gt/$gte/$lt/$lte on custom data now compare only when the stored value and the filter value are the same JSON type: numbers compare numerically, strings lexicographically, anything else never matches. Previously these fell back to PostgreSQL's JSONB type-rank ordering, which silently matched or excluded contacts based on type rather than value.
Documented the semantics and caveats (e.g. date strings must be ISO 8601 to sort correctly) in the module docs.
Tests
Added coverage for the new query semantics and for the editor's form ↔ filter conversions.
No migrations; existing filters keep working.