1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-05 17:53:12 +02:00

fix: remove lifecycle backfill on every startup

This commit is contained in:
Jaanus 2025-09-02 13:55:18 +03:00
parent 597456d4b5
commit 6c11b57c53
No known key found for this signature in database
6 changed files with 0 additions and 77 deletions

View File

@ -12,7 +12,6 @@ import type { ChangeRequestType } from '../../changeRequest.types';
import { Link } from 'react-router-dom';
import { ChangeRequestStatusBadge } from '../../ChangeRequestStatusBadge/ChangeRequestStatusBadge.tsx';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import { changesCount } from '../../changesCount.js';
import {
Separator,
StyledFlexAlignCenterBox,

View File

@ -26,8 +26,6 @@ export class FakeFeatureLifecycleStore implements IFeatureLifecycleStore {
return results.filter((result) => result !== null) as NewStage[];
}
async backfill() {}
private async insertOne(
featureLifecycleStage: FeatureLifecycleStage,
): Promise<boolean> {

View File

@ -82,7 +82,6 @@ export class FeatureLifecycleService {
}
listen() {
this.featureLifecycleStore.backfill();
this.eventStore.on(FEATURE_CREATED, async (event) => {
await this.featureInitialized(event.featureName);
});

View File

@ -25,5 +25,4 @@ export interface IFeatureLifecycleStore {
delete(feature: string): Promise<void>;
deleteAll(): Promise<void>;
deleteStage(stage: FeatureLifecycleStage): Promise<void>;
backfill(): Promise<void>;
}

View File

@ -37,26 +37,6 @@ export class FeatureLifecycleStore implements IFeatureLifecycleStore {
});
}
async backfill(): Promise<void> {
const stopTimer = this.timer('backfill');
await this.db.raw(`
INSERT INTO feature_lifecycles (feature, stage, created_at)
SELECT features.name, 'initial', features.created_at
FROM features
LEFT JOIN feature_lifecycles ON features.name = feature_lifecycles.feature
WHERE feature_lifecycles.feature IS NULL
`);
await this.db.raw(`
INSERT INTO feature_lifecycles (feature, stage, created_at)
SELECT features.name, 'archived', features.archived_at
FROM features
LEFT JOIN feature_lifecycles ON features.name = feature_lifecycles.feature AND feature_lifecycles.stage = 'archived'
WHERE features.archived_at IS NOT NULL
AND feature_lifecycles.feature IS NULL
`);
stopTimer();
}
async insert(
featureLifecycleStages: FeatureLifecycleStage[],
): Promise<NewStage[]> {

View File

@ -211,55 +211,3 @@ test('should be able to toggle between completed/uncompleted', async () => {
expect(body).toEqual([]);
});
test('should backfill intialized feature', async () => {
await app.createFeature('my_feature_c');
await featureLifecycleStore.delete('my_feature_c');
await featureLifecycleStore.backfill();
const { body } = await getFeatureLifecycle('my_feature_c');
expect(body).toEqual([
{ stage: 'initial', enteredStageAt: expect.any(String) },
]);
});
test('should backfill archived feature', async () => {
await app.createFeature('my_feature_d');
await app.archiveFeature('my_feature_d');
await featureLifecycleStore.delete('my_feature_d');
await featureLifecycleStore.backfill();
const { body } = await getFeatureLifecycle('my_feature_d');
expect(body).toEqual([
{ stage: 'initial', enteredStageAt: expect.any(String) },
{ stage: 'archived', enteredStageAt: expect.any(String) },
]);
});
test('should not backfill for existing lifecycle', async () => {
const environment = 'production'; // prod environment moves lifecycle to live stage
await app.createFeature('my_feature_e');
await app.enableFeature('my_feature_e', environment);
eventStore.emit(FEATURE_CREATED, { featureName: 'my_feature_e' });
eventBus.emit(CLIENT_METRICS_ADDED, [
{
featureName: 'my_feature_e',
environment: environment,
},
]);
await reachedStage('my_feature_e', 'live');
await featureLifecycleStore.backfill();
const { body } = await getFeatureLifecycle('my_feature_e');
expect(body).toEqual(
expect.arrayContaining([
{ stage: 'initial', enteredStageAt: expect.any(String) },
{ stage: 'pre-live', enteredStageAt: expect.any(String) },
{ stage: 'live', enteredStageAt: expect.any(String) },
]),
);
expect(body).toHaveLength(3);
});