mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
feat: frontend api clean up not needed columns (#6489)
1. Clean up not used fields 2. Fix a bug where segment was not attached
This commit is contained in:
parent
2997faecf6
commit
0cf7b324a5
@ -36,7 +36,6 @@ export default class ClientFeatureToggleReadModel
|
|||||||
'features.project as project',
|
'features.project as project',
|
||||||
'features.stale as stale',
|
'features.stale as stale',
|
||||||
'features.impression_data as impression_data',
|
'features.impression_data as impression_data',
|
||||||
'features.created_at as created_at',
|
|
||||||
'fe.variants as variants',
|
'fe.variants as variants',
|
||||||
'fe.enabled as enabled',
|
'fe.enabled as enabled',
|
||||||
'fe.environment as environment',
|
'fe.environment as environment',
|
||||||
@ -118,7 +117,6 @@ export default class ClientFeatureToggleReadModel
|
|||||||
project: row.project,
|
project: row.project,
|
||||||
stale: row.stale,
|
stale: row.stale,
|
||||||
type: row.type,
|
type: row.type,
|
||||||
dependencies: [],
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,6 +140,9 @@ export default class ClientFeatureToggleReadModel
|
|||||||
feature.strategies = feature.strategies || [];
|
feature.strategies = feature.strategies || [];
|
||||||
feature.strategies.push(this.rowToStrategy(row));
|
feature.strategies.push(this.rowToStrategy(row));
|
||||||
}
|
}
|
||||||
|
if (row.segment_id) {
|
||||||
|
this.addSegmentIdsToStrategy(feature, row);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
Object.values(featureTogglesByEnv).forEach((envFeatures) => {
|
Object.values(featureTogglesByEnv).forEach((envFeatures) => {
|
||||||
Object.values(envFeatures).forEach((feature) => {
|
Object.values(envFeatures).forEach((feature) => {
|
||||||
@ -158,6 +159,22 @@ export default class ClientFeatureToggleReadModel
|
|||||||
return featureTogglesByEnv;
|
return featureTogglesByEnv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private addSegmentIdsToStrategy(
|
||||||
|
feature: PartialDeep<IFeatureToggleClient>,
|
||||||
|
row: Record<string, any>,
|
||||||
|
) {
|
||||||
|
const strategy = feature.strategies?.find(
|
||||||
|
(s) => s?.id === row.strategy_id,
|
||||||
|
);
|
||||||
|
if (!strategy) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!strategy.segments) {
|
||||||
|
strategy.segments = [];
|
||||||
|
}
|
||||||
|
strategy.segments.push(row.segment_id);
|
||||||
|
}
|
||||||
|
|
||||||
private rowToStrategy(row: Record<string, any>): IStrategyConfig {
|
private rowToStrategy(row: Record<string, any>): IStrategyConfig {
|
||||||
const strategy: IStrategyConfig = {
|
const strategy: IStrategyConfig = {
|
||||||
id: row.strategy_id,
|
id: row.strategy_id,
|
||||||
|
@ -82,7 +82,10 @@ export class ProxyService {
|
|||||||
|
|
||||||
return definitions
|
return definitions
|
||||||
.filter((feature) =>
|
.filter((feature) =>
|
||||||
client.isEnabled(feature.name, { ...context, sessionId }),
|
client.isEnabled(feature.name, {
|
||||||
|
...context,
|
||||||
|
sessionId,
|
||||||
|
}),
|
||||||
)
|
)
|
||||||
.map((feature) => ({
|
.map((feature) => ({
|
||||||
name: feature.name,
|
name: feature.name,
|
||||||
@ -155,7 +158,10 @@ export class ProxyService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
await this.services.clientMetricsServiceV2.registerClientMetrics(
|
await this.services.clientMetricsServiceV2.registerClientMetrics(
|
||||||
{ ...metrics, environment },
|
{
|
||||||
|
...metrics,
|
||||||
|
environment,
|
||||||
|
},
|
||||||
ip,
|
ip,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user