mirror of
https://github.com/Unleash/unleash.git
synced 2025-08-23 13:46:45 +02:00
Chore: remove now-dead code.
This commit is contained in:
parent
11715a296b
commit
76169085e9
@ -100,40 +100,6 @@ const updateStrategyInCr = async (
|
||||
});
|
||||
};
|
||||
|
||||
describe.each([
|
||||
[
|
||||
'updateStrategy',
|
||||
(segmentId: number) =>
|
||||
updateStrategyInCr(randomId(), segmentId, FLAG_NAME),
|
||||
],
|
||||
[
|
||||
'addStrategy',
|
||||
(segmentId: number) => addStrategyToCr(segmentId, FLAG_NAME),
|
||||
],
|
||||
])('Should handle %s changes correctly', (_, addOrUpdateStrategy) => {
|
||||
test.each([
|
||||
['Draft', true],
|
||||
['In review', true],
|
||||
['Scheduled', true],
|
||||
['Approved', true],
|
||||
['Rejected', false],
|
||||
['Cancelled', false],
|
||||
['Applied', false],
|
||||
])(
|
||||
'Changes in %s CRs should make it %s',
|
||||
async (state, expectedOutcome) => {
|
||||
await createCR(state);
|
||||
|
||||
const segmentId = 3;
|
||||
await addOrUpdateStrategy(segmentId);
|
||||
|
||||
expect(
|
||||
await readModel.isSegmentUsedInActiveChangeRequests(segmentId),
|
||||
).toBe(expectedOutcome);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
test.each([
|
||||
['Draft', true],
|
||||
['In review', true],
|
||||
|
@ -10,7 +10,6 @@ type ExistingStrategy = NewStrategy & { id: string };
|
||||
export type ChangeRequestStrategy = NewStrategy | ExistingStrategy;
|
||||
|
||||
export interface IChangeRequestSegmentUsageReadModel {
|
||||
isSegmentUsedInActiveChangeRequests(segmentId: number): Promise<boolean>;
|
||||
getStrategiesUsedInActiveChangeRequests(
|
||||
segmentId: number,
|
||||
): Promise<ChangeRequestStrategy[]>;
|
||||
|
@ -6,24 +6,13 @@ import {
|
||||
export class FakeChangeRequestSegmentUsageReadModel
|
||||
implements IChangeRequestSegmentUsageReadModel
|
||||
{
|
||||
private isSegmentUsedInActiveChangeRequestsValue: boolean;
|
||||
strategiesUsedInActiveChangeRequests: ChangeRequestStrategy[];
|
||||
|
||||
constructor(
|
||||
isSegmentUsedInActiveChangeRequests = false,
|
||||
strategiesUsedInActiveChangeRequests = [],
|
||||
) {
|
||||
this.isSegmentUsedInActiveChangeRequestsValue =
|
||||
isSegmentUsedInActiveChangeRequests;
|
||||
|
||||
constructor(strategiesUsedInActiveChangeRequests = []) {
|
||||
this.strategiesUsedInActiveChangeRequests =
|
||||
strategiesUsedInActiveChangeRequests;
|
||||
}
|
||||
|
||||
public async isSegmentUsedInActiveChangeRequests(): Promise<boolean> {
|
||||
return this.isSegmentUsedInActiveChangeRequestsValue;
|
||||
}
|
||||
|
||||
public async getStrategiesUsedInActiveChangeRequests(): Promise<
|
||||
ChangeRequestStrategy[]
|
||||
> {
|
||||
|
@ -12,23 +12,6 @@ export class ChangeRequestSegmentUsageReadModel
|
||||
constructor(db: Db) {
|
||||
this.db = db;
|
||||
}
|
||||
public async isSegmentUsedInActiveChangeRequests(
|
||||
segmentId: number,
|
||||
): Promise<boolean> {
|
||||
const result = await this.db.raw(
|
||||
`SELECT events.*
|
||||
FROM change_request_events events
|
||||
JOIN change_requests cr ON events.change_request_id = cr.id
|
||||
WHERE cr.state IN ('Draft', 'In review', 'Scheduled', 'Approved')
|
||||
AND events.action IN ('updateStrategy', 'addStrategy');`,
|
||||
);
|
||||
|
||||
const isUsed = result.rows.some((row) =>
|
||||
row.payload?.segments?.includes(segmentId),
|
||||
);
|
||||
|
||||
return isUsed;
|
||||
}
|
||||
|
||||
mapRow = (row): ChangeRequestStrategy => {
|
||||
const { payload, project, environment, feature } = row;
|
||||
|
Loading…
Reference in New Issue
Block a user