mirror of
https://github.com/Unleash/unleash.git
synced 2025-08-04 13:48:56 +02:00
refactor: read project ids in memory (#3965)
This commit is contained in:
parent
f8ca7c91df
commit
32ae15741c
@ -45,6 +45,13 @@ export class PlaygroundService {
|
|||||||
),
|
),
|
||||||
this.segmentService.getActive(),
|
this.segmentService.getActive(),
|
||||||
]);
|
]);
|
||||||
|
const featureProject: Record<string, string> = features.reduce(
|
||||||
|
(obj, feature) => {
|
||||||
|
obj[feature.name] = feature.project;
|
||||||
|
return obj;
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
);
|
||||||
|
|
||||||
const [head, ...rest] = features;
|
const [head, ...rest] = features;
|
||||||
if (!head) {
|
if (!head) {
|
||||||
@ -68,37 +75,29 @@ export class PlaygroundService {
|
|||||||
? new Date(context.currentTime)
|
? new Date(context.currentTime)
|
||||||
: undefined,
|
: undefined,
|
||||||
};
|
};
|
||||||
const output: PlaygroundFeatureSchema[] = await Promise.all(
|
const output: PlaygroundFeatureSchema[] = client
|
||||||
client
|
.getFeatureToggleDefinitions()
|
||||||
.getFeatureToggleDefinitions()
|
.map((feature: FeatureInterface) => {
|
||||||
.map(async (feature: FeatureInterface) => {
|
const strategyEvaluationResult: FeatureStrategiesEvaluationResult =
|
||||||
const strategyEvaluationResult: FeatureStrategiesEvaluationResult =
|
client.isEnabled(feature.name, clientContext);
|
||||||
client.isEnabled(feature.name, clientContext);
|
|
||||||
|
|
||||||
const isEnabled =
|
const isEnabled =
|
||||||
strategyEvaluationResult.result === true &&
|
strategyEvaluationResult.result === true &&
|
||||||
feature.enabled;
|
feature.enabled;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isEnabled,
|
isEnabled,
|
||||||
isEnabledInCurrentEnvironment: feature.enabled,
|
isEnabledInCurrentEnvironment: feature.enabled,
|
||||||
strategies: {
|
strategies: {
|
||||||
result: strategyEvaluationResult.result,
|
result: strategyEvaluationResult.result,
|
||||||
data: strategyEvaluationResult.strategies,
|
data: strategyEvaluationResult.strategies,
|
||||||
},
|
},
|
||||||
projectId:
|
projectId: featureProject[feature.name],
|
||||||
await this.featureToggleService.getProjectId(
|
variant: client.getVariant(feature.name, clientContext),
|
||||||
feature.name,
|
name: feature.name,
|
||||||
),
|
variants: variantsMap[feature.name] || [],
|
||||||
variant: client.getVariant(
|
};
|
||||||
feature.name,
|
});
|
||||||
clientContext,
|
|
||||||
),
|
|
||||||
name: feature.name,
|
|
||||||
variants: variantsMap[feature.name] || [],
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user