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

feat(ForcedDecisions): add forced-decisions APIs to OptimizelyUserContext #233

Merged
merged 28 commits into from
Nov 4, 2021

Conversation

mnoman09
Copy link
Contributor

@mnoman09 mnoman09 commented Oct 6, 2021

Summary

Add a set of new APIs for forced-decisions to OptimizelyUserContext:

  • setForcedDecision
  • getForcedDecision
  • removeForcedDecision
  • removeAllForcedDecision

Test plan

  • unit tests for the new APIs
  • FSC tests with new test cases

@mnoman09 mnoman09 removed their assignment Oct 6, 2021
@coveralls
Copy link

coveralls commented Oct 6, 2021

Coverage Status

Coverage increased (+0.3%) to 97.782% when pulling 32122b7 on mnoman/forcedDecision into e46fde5 on master.

@mnoman09 mnoman09 requested a review from jaeopt October 12, 2021 13:53
@mnoman09 mnoman09 marked this pull request as ready for review October 12, 2021 13:53
@mnoman09 mnoman09 requested a review from a team as a code owner October 12, 2021 13:53
Copy link
Contributor

@jaeopt jaeopt left a comment

Choose a reason for hiding this comment

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

All changes look good! A couple of more changes suggested.

@mnoman09 mnoman09 requested a review from jaeopt October 14, 2021 15:48
@mnoman09 mnoman09 removed their assignment Oct 14, 2021
Copy link
Contributor

@jaeopt jaeopt left a comment

Choose a reason for hiding this comment

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

LGTM

$flagRules = $this->getAllRulesForFlag($flag);

foreach ($flagRules as $rule) {
$flagVariations = array_merge($flagVariations, array_filter(array_values($rule->getVariations()), function ($variation) use ($flagVariations) {

Choose a reason for hiding this comment

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

My understanding of closures in PHP suggests this is copying the value of $flagVariations and not referencing it. Not sure if this could provide an edge case where the $flagVariations array is modified outside of this set of functions.

if (!$this->getConfig()) {
$this->_logger->log(
Logger::ERROR,
"Optimizely SDK not configured properly yet."

Choose a reason for hiding this comment

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

Is there a static message for this that can be referenced?

@dustin-sier dustin-sier self-requested a review November 3, 2021 00:43
Copy link

@dustin-sier dustin-sier left a comment

Choose a reason for hiding this comment

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

Have a few questions, once that's done LGTM

public function findForcedDecision($context)
{
$foundVariationKey = null;
if (!$this->forcedDecisions) {

Choose a reason for hiding this comment

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

Any reason to do this vs. isset?

Copy link

@dustin-sier dustin-sier left a comment

Choose a reason for hiding this comment

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

Looks good!

@msohailhussain msohailhussain merged commit 0e7cefc into master Nov 4, 2021
@msohailhussain msohailhussain deleted the mnoman/forcedDecision branch November 4, 2021 18:47
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.

8 participants