From b9a82801772e9a7ec7be132372ddf8f568e75542 Mon Sep 17 00:00:00 2001 From: Jaanus Sellin Date: Wed, 7 Feb 2024 12:53:25 +0200 Subject: [PATCH] fix: now archived features are not marked as stale anymore (#6149) --- .../feature-toggle/feature-toggle-store.ts | 2 +- .../tests/feature-toggle-store.e2e.test.ts | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/lib/features/feature-toggle/feature-toggle-store.ts b/src/lib/features/feature-toggle/feature-toggle-store.ts index 686685f8bde0..b730c858c93d 100644 --- a/src/lib/features/feature-toggle/feature-toggle-store.ts +++ b/src/lib/features/feature-toggle/feature-toggle-store.ts @@ -677,7 +677,7 @@ export default class FeatureToggleStore implements IFeatureToggleStore { WHERE feature_types.id = features.type) * INTERVAL '1 day'))) as current_staleness FROM features - WHERE NOT stale = true`, + WHERE NOT stale = true AND archived_at IS NULL`, [currentTime || this.db.fn.now()], ); diff --git a/src/lib/features/feature-toggle/tests/feature-toggle-store.e2e.test.ts b/src/lib/features/feature-toggle/tests/feature-toggle-store.e2e.test.ts index 2ee5b000a563..ab6a45146ed9 100644 --- a/src/lib/features/feature-toggle/tests/feature-toggle-store.e2e.test.ts +++ b/src/lib/features/feature-toggle/tests/feature-toggle-store.e2e.test.ts @@ -167,6 +167,27 @@ describe('potentially_stale marking', () => { expect(markedToggles).toStrictEqual([]); }); + test('it does not mark archived toggles potentially stale', async () => { + const features: FeatureToggleInsert[] = [ + { + name: 'feature1', + type: 'release', + archived: true, + createdByUserId: 9999, + }, + ]; + await Promise.all( + features.map((feature) => + featureToggleStore.create('default', feature), + ), + ); + const markedToggles = + await featureToggleStore.updatePotentiallyStaleFeatures( + getFutureTimestamp(1000), + ); + expect(markedToggles).toStrictEqual([]); + }); + test('it does not return toggles previously marked as potentially_stale', async () => { const features: FeatureToggleInsert[] = [ {