mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
refactor: encapsulate playground limit in service (#7700)
This commit is contained in:
parent
50167d4f9e
commit
c828d01135
@ -101,12 +101,18 @@ export class PlaygroundService {
|
|||||||
projects: typeof ALL | string[],
|
projects: typeof ALL | string[],
|
||||||
environments: string[],
|
environments: string[],
|
||||||
context: SdkContextSchema,
|
context: SdkContextSchema,
|
||||||
limit: number,
|
|
||||||
userId: number,
|
userId: number,
|
||||||
): Promise<{
|
): Promise<{
|
||||||
result: AdvancedPlaygroundFeatureEvaluationResult[];
|
result: AdvancedPlaygroundFeatureEvaluationResult[];
|
||||||
invalidContextProperties: string[];
|
invalidContextProperties: string[];
|
||||||
}> {
|
}> {
|
||||||
|
// used for runtime control, do not remove
|
||||||
|
const { payload } = this.flagResolver.getVariant('advancedPlayground');
|
||||||
|
const limit =
|
||||||
|
payload?.value && Number.isInteger(Number.parseInt(payload?.value))
|
||||||
|
? Number.parseInt(payload?.value)
|
||||||
|
: 15000;
|
||||||
|
|
||||||
const segments = await this.segmentReadModel.getActive();
|
const segments = await this.segmentReadModel.getActive();
|
||||||
|
|
||||||
let filteredProjects: typeof projects = projects;
|
let filteredProjects: typeof projects = projects;
|
||||||
|
@ -118,19 +118,12 @@ export default class PlaygroundController extends Controller {
|
|||||||
res: Response<AdvancedPlaygroundResponseSchema>,
|
res: Response<AdvancedPlaygroundResponseSchema>,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const { user } = req;
|
const { user } = req;
|
||||||
// used for runtime control, do not remove
|
|
||||||
const { payload } = this.flagResolver.getVariant('advancedPlayground');
|
|
||||||
const limit =
|
|
||||||
payload?.value && Number.isInteger(Number.parseInt(payload?.value))
|
|
||||||
? Number.parseInt(payload?.value)
|
|
||||||
: 15000;
|
|
||||||
|
|
||||||
const { result, invalidContextProperties } =
|
const { result, invalidContextProperties } =
|
||||||
await this.playgroundService.evaluateAdvancedQuery(
|
await this.playgroundService.evaluateAdvancedQuery(
|
||||||
req.body.projects || '*',
|
req.body.projects || '*',
|
||||||
req.body.environments,
|
req.body.environments,
|
||||||
req.body.context,
|
req.body.context,
|
||||||
limit,
|
|
||||||
extractUserIdFromUser(user),
|
extractUserIdFromUser(user),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user