Skip to content

Commit

Permalink
refactor: encapsulate playground limit in service (#7700)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwasniew authored Jul 30, 2024
1 parent 50167d4 commit c828d01
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
8 changes: 7 additions & 1 deletion src/lib/features/playground/playground-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,18 @@ export class PlaygroundService {
projects: typeof ALL | string[],
environments: string[],
context: SdkContextSchema,
limit: number,
userId: number,
): Promise<{
result: AdvancedPlaygroundFeatureEvaluationResult[];
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();

let filteredProjects: typeof projects = projects;
Expand Down
7 changes: 0 additions & 7 deletions src/lib/features/playground/playground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,12 @@ export default class PlaygroundController extends Controller {
res: Response<AdvancedPlaygroundResponseSchema>,
): Promise<void> {
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 } =
await this.playgroundService.evaluateAdvancedQuery(
req.body.projects || '*',
req.body.environments,
req.body.context,
limit,
extractUserIdFromUser(user),
);

Expand Down

0 comments on commit c828d01

Please sign in to comment.