Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "src/test/java/com/flagsmith/flagengine/enginetestdata"]
path = src/test/java/com/flagsmith/flagengine/enginetestdata
url = git@github.com:Flagsmith/engine-test-data.git
tag = v3.2.1
tag = v3.4.1
23 changes: 11 additions & 12 deletions src/main/java/com/flagsmith/flagengine/Engine.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,22 +124,20 @@ private static Flags evaluateFeatures(

if (contextFeatures != null) {
for (FeatureContext featureContext : contextFeatures.getAdditionalProperties().values()) {
String reason;
if (segmentFeatureContexts.containsKey(featureContext.getName())) {
ImmutablePair<String, FeatureContext> segmentNameFeaturePair = segmentFeatureContexts
.get(featureContext.getName());
featureContext = segmentNameFeaturePair.getRight();
flags.setAdditionalProperty(
featureContext.getName(),
new FlagResult().withEnabled(featureContext.getEnabled())
.withName(featureContext.getName())
.withValue(featureContext.getValue())
.withReason(
"TARGETING_MATCH; segment=" + segmentNameFeaturePair.getLeft())
.withMetadata(featureContext.getMetadata()));
reason = "TARGETING_MATCH; segment=" + segmentNameFeaturePair.getLeft();
} else {
flags.setAdditionalProperty(featureContext.getName(),
getFlagResultFromFeatureContext(featureContext, identityKey));
reason = "DEFAULT";
}
flags.setAdditionalProperty(featureContext.getName(),
getFlagResultFromFeatureContext(
featureContext,
identityKey,
reason));
}
}

Expand All @@ -148,7 +146,8 @@ private static Flags evaluateFeatures(

private static FlagResult getFlagResultFromFeatureContext(
FeatureContext featureContext,
String identityKey) {
String identityKey,
String reason) {
if (identityKey != null) {
List<FeatureValue> variants = featureContext.getVariants();
if (variants != null) {
Expand Down Expand Up @@ -183,7 +182,7 @@ private static FlagResult getFlagResultFromFeatureContext(
return new FlagResult().withEnabled(featureContext.getEnabled())
.withName(featureContext.getName())
.withValue(featureContext.getValue())
.withReason("DEFAULT")
.withReason(reason)
.withMetadata(featureContext.getMetadata());
}
}
2 changes: 1 addition & 1 deletion src/test/java/com/flagsmith/flagengine/enginetestdata
Submodule enginetestdata updated 104 files