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

Implement experiment sorting #444

Merged
merged 1 commit into from Dec 14, 2023
Merged

Implement experiment sorting #444

merged 1 commit into from Dec 14, 2023

Conversation

spokenbird
Copy link
Contributor

This PR implements a beforeSaveAction SetExperimentGroups that runs on the first post in the digital assister flow (the Language Preferences page). The SetExperimentGroups action uses an enum with values CONTROL, LINK and, APPLY along with a simple algorithm that randomly assigns one of the three enum values.

The assigned value is stored in the Submissions input data JSON as experimentGroup.

Co-authored-by: Luigi <luigi@codeforamerica.org>
@sree-cfa sree-cfa temporarily deployed to test-la-doc-uploader-pr-444 December 13, 2023 23:53 Inactive
switch(group) {
case 0 -> submission.getInputData().put("experimentGroup", ExperimentGroup.CONTROL);
case 1 -> submission.getInputData().put("experimentGroup", ExperimentGroup.LINK);
case 2 -> submission.getInputData().put("experimentGroup", ExperimentGroup.APPLY);
Copy link
Contributor

@sree-cfa sree-cfa Dec 14, 2023

Choose a reason for hiding this comment

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

Do enums get saved as strings in the db? If there's some conversion needed, might be nice to have a helper method in the enum class Actually I think valueOf will take care of that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like they are automatically converted to strings. Here is how they look in the JSON:
Screenshot 2023-12-14 at 10 39 45 AM

Copy link
Contributor

@sree-cfa sree-cfa left a comment

Choose a reason for hiding this comment

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

LGTM

@spokenbird spokenbird merged commit 9a7ccde into main Dec 14, 2023
5 checks passed
@spokenbird spokenbird deleted the experiment-treatments branch December 14, 2023 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants