Skip to content
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

Merged
merged 2 commits into from
Sep 19, 2022

Conversation

krithika369
Copy link
Collaborator

@krithika369 krithika369 commented Sep 15, 2022

What this PR does / why we need it:
When multiple experiments are matched by the Fetch Treatment API, the hierarchical experiment filters ensure that ultimately, only one experiment will be selected. However, in a case where there are multiple experiments after filterByMatchStrength and there are missing segmenter values to the Fetch Treatment request, the filterByLookupOrder function would simply eliminate the experiment(s) from the matches. But, in fact, the overall matches should only be updated if there are non-zero matches for a given segmenter value (which will automatically handle nil segmenter values).

Which issue(s) this PR fixes:

This PR addresses the issue above by only updating the filtered experiments if the matches in the current iteration is non-zero, much like the other filters for hierarchical experiments.

@krithika369 krithika369 self-assigned this Sep 15, 2022
@krithika369 krithika369 requested a review from a team September 16, 2022 00:29
Copy link
Contributor

@terryyylim terryyylim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes, @krithika369! LGTM, left some comments/questions for clarification 🙏🏻

@@ -128,38 +128,37 @@ func (es *experimentService) filterByLookupOrder(
filtered := matches
Copy link
Contributor

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 🤔

Copy link
Collaborator Author

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.

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for renaming this 👍🏻 , segmenterMatch really didn't make any sense as I was reviewing these changes.

}
}
}
}
}
filtered = currentFilteredList
// currentFilteredList could be 0 in case of weak matches
if len(currentFilteredList) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to affirm my understanding, this is because orderedValues could potentially be empty right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. Added more info in the comment now.

@krithika369 krithika369 merged commit fac3bc6 into caraml-dev:main Sep 19, 2022
@krithika369 krithika369 deleted the bugfix_optional_segmenters branch September 19, 2022 03:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants