Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract playground steps #3966

Merged
merged 4 commits into from
Jun 13, 2023
Merged

Extract playground steps #3966

merged 4 commits into from
Jun 13, 2023

Conversation

kwasniew
Copy link
Contributor

@kwasniew kwasniew commented Jun 13, 2023

About the changes

  • extracting individual steps in the query evaluation algorithm. This will be needed for the advanced query that is currently only drafted in code to manually test the results
  • moved cartesian product generator to playground since it's only used in one place

Important files

Discussion points

@vercel
Copy link

vercel bot commented Jun 13, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) Visit Preview Jun 13, 2023 9:16am
unleash-monorepo-frontend ⬜️ Ignored (Inspect) Jun 13, 2023 9:16am

@@ -21,7 +21,7 @@ export const generateCombinations = <T extends Record<string, string>>(
) as T[];
};

export const generateObjectCombinations = <T extends Record<string, string>>(
export const generateObjectCombinations = <T extends Record<string, any>>(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will persist the input type instead of forcing string

@@ -64,7 +64,7 @@ export const offlineUnleashClient = async ({
},
});

client.start();
await client.start();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

start is async so await is needed. w/o it the code would break if we switched to node.js sdk

@@ -68,39 +92,66 @@ export class PlaygroundService {
? new Date(context.currentTime)
: undefined,
};
const output: PlaygroundFeatureSchema[] = await Promise.all(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extracting into a shared method that will be reused in advanced query evaluation


private async evaluate({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is extract method refactoring - no new code in here


return output;
}
}

private async resolveFeatures(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extract method refactoring - no new code in here

);
const contexts = generateObjectCombinations(context);

const results = await Promise.all(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will be thoroughly tested in subsequent PRs. Here I wrote this to manually test the combinatorial generation and drive the extract method refactoring

import { FeatureConfigurationClient } from '../../types/stores/feature-strategies-store';
import { generateObjectCombinations } from './generateObjectCombinations';

type EvaluationInput = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

introducing a type to capture what is actually used for the playground evaluation. Those are the values that we derive from the user input by going to our stores

Copy link
Contributor

@andreas-unleash andreas-unleash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG

@kwasniew kwasniew merged commit 7d69750 into main Jun 13, 2023
10 checks passed
@kwasniew kwasniew deleted the extract-playground-steps branch June 13, 2023 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants