mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-09 00:18:00 +01:00
fix: exclude archived features in segments count (#7897)
This commit is contained in:
parent
cf83043d8a
commit
c2e6f74bfa
@ -948,4 +948,39 @@ describe('detect strategy usage in change requests', () => {
|
|||||||
{ usedInFeatures: 0, usedInProjects: 0 },
|
{ usedInFeatures: 0, usedInProjects: 0 },
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('If a segment is used in an archived feature it should be excluded from count - enterprise version', async () => {
|
||||||
|
await app.createSegment({
|
||||||
|
name: 'a',
|
||||||
|
constraints: [],
|
||||||
|
});
|
||||||
|
const flag = mockFeatureFlag();
|
||||||
|
await createFeatureFlag(enterpriseApp, flag);
|
||||||
|
const [segment] = await enterpriseFetchSegments();
|
||||||
|
|
||||||
|
await addStrategyToFeatureEnv(
|
||||||
|
enterpriseApp,
|
||||||
|
{ ...flag.strategies[0] },
|
||||||
|
'default',
|
||||||
|
flag.name,
|
||||||
|
);
|
||||||
|
|
||||||
|
const [feature] = await fetchFeatures();
|
||||||
|
const [strategy] = await fetchFeatureStrategies(feature.name);
|
||||||
|
|
||||||
|
const strategyId = strategy.id;
|
||||||
|
await addSegmentsToStrategy([segment.id], strategyId!);
|
||||||
|
|
||||||
|
const segments = await enterpriseFetchSegments();
|
||||||
|
expect(segments).toMatchObject([
|
||||||
|
{ usedInFeatures: 1, usedInProjects: 1 },
|
||||||
|
]);
|
||||||
|
|
||||||
|
await enterpriseApp.archiveFeature(flag.name, 'default');
|
||||||
|
|
||||||
|
const segmentsAfter = await enterpriseFetchSegments();
|
||||||
|
expect(segmentsAfter).toMatchObject([
|
||||||
|
{ usedInFeatures: 0, usedInProjects: 0 },
|
||||||
|
]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -187,7 +187,13 @@ export default class SegmentStore implements ISegmentStore {
|
|||||||
T.featureStrategies,
|
T.featureStrategies,
|
||||||
`${T.featureStrategies}.id`,
|
`${T.featureStrategies}.id`,
|
||||||
`${T.featureStrategySegment}.feature_strategy_id`,
|
`${T.featureStrategySegment}.feature_strategy_id`,
|
||||||
);
|
)
|
||||||
|
.leftJoin(
|
||||||
|
T.features,
|
||||||
|
`${T.featureStrategies}.feature_name`,
|
||||||
|
`${T.features}.name`,
|
||||||
|
)
|
||||||
|
.where(`${T.features}.archived_at`, null);
|
||||||
|
|
||||||
this.mergeCurrentUsageWithCombinedData(
|
this.mergeCurrentUsageWithCombinedData(
|
||||||
combinedUsageData,
|
combinedUsageData,
|
||||||
|
Loading…
Reference in New Issue
Block a user