-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugfix: Cater to optional segmenter matches in filterByLookupOrder #35
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,38 +128,37 @@ func (es *experimentService) filterByLookupOrder( | |
filtered := matches | ||
for _, segmenter := range segmenters { | ||
orderedValues := filters[segmenter] | ||
if len(orderedValues) == 1 { | ||
continue | ||
} | ||
|
||
currentFilteredList := []*models.ExperimentMatch{} | ||
segmenterType := segmenterTypes[segmenter] | ||
for _, transformedValue := range orderedValues { | ||
if len(currentFilteredList) == 0 { | ||
for _, segmenterMatch := range filtered { | ||
segmenterMatchedValue := segmenterMatch.SegmenterMatches[segmenter] | ||
for _, experiment := range filtered { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for renaming this 👍🏻 , |
||
segmenterMatchedValue := experiment.SegmenterMatches[segmenter] | ||
switch segmenterType { | ||
case "string": | ||
if transformedValue.GetString_() == segmenterMatchedValue.Value.GetString_() { | ||
currentFilteredList = append(currentFilteredList, segmenterMatch) | ||
currentFilteredList = append(currentFilteredList, experiment) | ||
} | ||
case "integer": | ||
if transformedValue.GetInteger() == segmenterMatchedValue.Value.GetInteger() { | ||
currentFilteredList = append(currentFilteredList, segmenterMatch) | ||
currentFilteredList = append(currentFilteredList, experiment) | ||
} | ||
case "real": | ||
if transformedValue.GetReal() == segmenterMatchedValue.Value.GetReal() { | ||
currentFilteredList = append(currentFilteredList, segmenterMatch) | ||
currentFilteredList = append(currentFilteredList, experiment) | ||
} | ||
case "bool": | ||
if transformedValue.GetBool() == segmenterMatchedValue.Value.GetBool() { | ||
currentFilteredList = append(currentFilteredList, segmenterMatch) | ||
currentFilteredList = append(currentFilteredList, experiment) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
filtered = currentFilteredList | ||
// currentFilteredList could be 0 in case of weak matches | ||
if len(currentFilteredList) > 0 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to affirm my understanding, this is because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct. Added more info in the comment now. |
||
filtered = currentFilteredList | ||
} | ||
} | ||
|
||
return filtered | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if the above
// Stop search when we have at least 1 match
is still relevant here. Feels like it should be shifted down 🤔There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed this comment - not sure it had much significance previously either. Removed it. Thanks for pointing out.