From 42f3160abebe129f6a9d786d40b03d4ff0cfbcaf Mon Sep 17 00:00:00 2001 From: Vyacheslav Matyukhin Date: Fri, 29 Apr 2022 00:17:46 +0400 Subject: [PATCH] fix: inverted binary forecasts, fixes #76 --- src/web/questions/components/QuestionOptions.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/web/questions/components/QuestionOptions.tsx b/src/web/questions/components/QuestionOptions.tsx index e200018..33cdf17 100644 --- a/src/web/questions/components/QuestionOptions.tsx +++ b/src/web/questions/components/QuestionOptions.tsx @@ -113,29 +113,30 @@ export const QuestionOptions: React.FC<{ options: Option[] }> = ({ options.length === 2 && (options[0].name === "Yes" || options[0].name === "No"); - const optionsSorted = options.sort((a, b) => b.probability - a.probability); - const optionsMax5 = !!optionsSorted.slice ? optionsSorted.slice(0, 5) : []; // display max 5 options. - if (isBinary) { + const yesOption = options.find((o) => o.name === "Yes"); return (
- {formatProbability(options[0].probability)} + {formatProbability(yesOption.probability)} - {primaryEstimateAsText(options[0].probability)} + {primaryEstimateAsText(yesOption.probability)}
); } else { + const optionsSorted = options.sort((a, b) => b.probability - a.probability); + const optionsMax5 = !!optionsSorted.slice ? optionsSorted.slice(0, 5) : []; // display max 5 options. + return (
{optionsMax5.map((option, i) => (