-
Notifications
You must be signed in to change notification settings - Fork 2
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
fix: flag not found when using dependency flag in targeting rule #95
Conversation
55e26df
to
f9fdd1b
Compare
f9fdd1b
to
d369990
Compare
3925425
to
0d726a7
Compare
@cre8ivejp please help me to take a look. |
src/evaluator/local.ts
Outdated
} | ||
const prerequisiteFeatures = await this.getPrerequisiteFeatures(feature); | ||
|
||
const prerequisiteFeatures = await this.getPrerequisiteFeaturesFromCache(preFlagIDs); | ||
return targetFeatures.concat(prerequisiteFeatures); |
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.
Just confirming, this concat will add the list after the this flag, right?
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.
yes, its the same with this go code
But I updated the code for more easy readable using new typescript syntax [...]
async getTargetFeatures(feature: Feature): Promise<Feature[]> {
// Check if the flag depends on other flags.
// If not, we return only the target flag
const preFlagIDs = getFeatureIDsDependsOn(feature);
if (preFlagIDs.length === 0) {
return [feature];
}
const prerequisiteFeatures = await this.getPrerequisiteFeaturesFromCache(preFlagIDs);
return [
feature,
...prerequisiteFeatures,
];
}
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.
Nice. Thank you!
Part of bucketeer-io/bucketeer#1552
Refers to https://github.com/bucketeer-io/go-server-sdk/pull/157/files
This pull request includes several changes to improve the evaluation process and testing in the project. The most important changes include updating dependencies, refactoring test cases, and enhancing the
LocalEvaluator
class.Dependency updates:
@bucketeer/evaluation
from0.0.1
to0.0.3
in thepackage.json
file.Test improvements:
Refactored imports in
src/__tests__/client_assert_get_evaluation_rq.ts
to directly importBKTClientImpl
fromclient
.Added new test cases for
protoReasonToReason
function insrc/__tests__/evaluator/protoReasonToReason.ts
.Modified multiple test cases in
src/__tests__/evaluator/evaluator.ts
to usetry-catch
blocks instead of.catch
for error handling. [1] [2] [3] [4] [5]Their tests will fail if the expected error is not throw
Added new test cases for
getTargetFeatures
,findEvaluation
, andgetTargetFeatures
methods insrc/__tests__/evaluator/evaluator.ts
.Enhancements to
LocalEvaluator
class:findEvaluation
method to be public.getTargetFeatures
method to handle prerequisite features more efficiently.getPrerequisiteFeaturesFromCache
to replacegetPrerequisiteFeatures
.protoReasonToReason
function fromsrc/evaluator/local.ts
.