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

Fix organization prior settings #2518

Merged
merged 2 commits into from
May 14, 2024
Merged

Fix organization prior settings #2518

merged 2 commits into from
May 14, 2024

Conversation

lukesonnet
Copy link
Contributor

Fix bug with setting priors at the org level

Previously, settings from the userContext (which pulls from the DB) would be clobbering the sub-fields of metricDefaults that were initialized in the form defaultValues. This isn't a problem for other fields that are not nested, but it is a problem for metricDefaults.priorSettings which will be missing in most databases.

This fixes that issue in the org settings and makes the FE a bit more robust to this issue.

A migration might be a better solution, to be honest.

Copy link
Collaborator

@bttf bttf left a comment

Choose a reason for hiding this comment

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

mostly minor comments

Comment on lines +399 to +404
(metricDefaults.priorSettings ?? {
override: false,
proper: false,
mean: 0,
stddev: DEFAULT_PROPER_PRIOR_STDDEV,
}),
Copy link
Collaborator

Choose a reason for hiding this comment

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

should the { override: false, ... } object be defined as a default in shared/constants?

// Metric defaults are nested, so take existing metric defaults only if
// they exist and are not empty
Object.keys(newVal[k]).forEach((kk) => {
newVal[k][kk] = settings?.[k]?.[k] ?? newVal[k][kk];
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is accomplishing the same as if you used the spread operator (...), with settings spread first. Any reason you wouldn't want to do it that way?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It needs to spread settings?.[k] which could work.

Copy link

Your preview environment pr-2518-bttf has been deployed.

Preview environment endpoints are available at:

@lukesonnet
Copy link
Contributor Author

ty, landing in the interest of time, your feedback is useful and i can do it in a follow up.

@lukesonnet lukesonnet merged commit 2e41201 into main May 14, 2024
3 checks passed
@lukesonnet lukesonnet deleted the ls/prior-settings-bugfix branch May 14, 2024 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants