Undo re-flipping risk for inverse metrics #2356
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
FE bugfix for risk for inverse metrics
Both our stats engine AND our FE after some recent refactors were flipping "risk" for inverse metrics, meaning we were flipping it, and then flipping it back.
This PR undoes this by having the FE receive risk as expected for inverse metrics from the stats engine (which is the same as how it deals with ChanceToWin, which also is returned from the stats engine depending on
inverse
). Users will have their FE reflect the right data as soon as they get this PR in their GrowthBook.But note that the results data in the DB depend on
metric.inverse
for both chance to win and risk, which means if the metric def changes you have to refresh results to get the UI to show the right data.Rip out unused risk code
Also noticed we had some duplicated risk logic that was never used; we only used a duplication of the business logic computing relative risk depending on
inverse
to check if risk existed (in the olduseRiskVariations
method). I simplified this to just checkhasRisk
which was all that method was used for anyways (presumably after ripping out the old results UI).Screenshots
Bugged before
![Screenshot 2024-04-08 at 10 09 23 AM](https://private-user-images.githubusercontent.com/5298599/320591061-d361362e-a863-4b2a-ad9d-9009a752b006.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA1ODUyOTIsIm5iZiI6MTcyMDU4NDk5MiwicGF0aCI6Ii81Mjk4NTk5LzMyMDU5MTA2MS1kMzYxMzYyZS1hODYzLTRiMmEtYWQ5ZC05MDA5YTc1MmIwMDYucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcxMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MTBUMDQxNjMyWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ODk1YjBiZmFiYmY2ZDgyYTViOThlZjc4MzI4ODlkMzU3MGIzOGQ3ZmM5YWViYzQ4MmMxNGI5MjAwMzMwZTBhNSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.5q6Ws6MEmJY11tj-0LCUpDsjBgA92Qc-0OjMduZyOaA)
Fixed after (no need to re-run results).
![Screenshot 2024-04-08 at 10 09 53 AM](https://private-user-images.githubusercontent.com/5298599/320591096-744c4653-3130-4437-915f-32cde75e4b96.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA1ODUyOTIsIm5iZiI6MTcyMDU4NDk5MiwicGF0aCI6Ii81Mjk4NTk5LzMyMDU5MTA5Ni03NDRjNDY1My0zMTMwLTQ0MzctOTE1Zi0zMmNkZTc1ZTRiOTYucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcxMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MTBUMDQxNjMyWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MDdjNzhlYjcyMmNkYzY3Y2FlMjg4N2RmYzhkN2IxZTg0MDI4YzdjOGQ2ZWQ3MGY1ZTAyYmFmNGE4OWE0Nzk0OSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.F3mcXVHlG21O07B2kavbVtM1k3c7RCrYLIs-IsuyGGs)