-
Notifications
You must be signed in to change notification settings - Fork 31
feat: limit discrete questions to 50 options max #4336
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
Changes from all commits
c3f21ec
000e462
2b77820
65e3ebd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -13,6 +13,7 @@ import { FormError, Input } from "@/components/ui/form_field"; | |||||||||||||||||||||
| import { | ||||||||||||||||||||||
| AggregationMethod, | ||||||||||||||||||||||
| DefaultInboundOutcomeCount, | ||||||||||||||||||||||
| MaxDiscreteOptionCount, | ||||||||||||||||||||||
| QuestionDraft, | ||||||||||||||||||||||
| QuestionWithNumericForecasts, | ||||||||||||||||||||||
| } from "@/types/question"; | ||||||||||||||||||||||
|
|
@@ -137,7 +138,10 @@ const NumericQuestionInput: React.FC<{ | |||||||||||||||||||||
| inbound_outcome_count: isNil(defaultInboundOutcomeCount) | ||||||||||||||||||||||
| ? questionType !== QuestionType.Discrete || isNil(min) || isNil(max) | ||||||||||||||||||||||
| ? DefaultInboundOutcomeCount | ||||||||||||||||||||||
| : Math.max(3, Math.min(200, Math.round((max - min) / step) + 1)) | ||||||||||||||||||||||
| : Math.max( | ||||||||||||||||||||||
| 3, | ||||||||||||||||||||||
| Math.min(MaxDiscreteOptionCount, Math.round((max - min) / step) + 1) | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| : defaultInboundOutcomeCount, | ||||||||||||||||||||||
| aggregations: { | ||||||||||||||||||||||
| recency_weighted: { history: [], latest: undefined }, | ||||||||||||||||||||||
|
|
@@ -194,9 +198,9 @@ const NumericQuestionInput: React.FC<{ | |||||||||||||||||||||
| t.rich("stepError0", { halfRange: (max - min) / 2 }) | ||||||||||||||||||||||
| ); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| if (step != 0 && step < (max - min) / 200) { | ||||||||||||||||||||||
| if (step != 0 && step < (max - min) / MaxDiscreteOptionCount) { | ||||||||||||||||||||||
| current_errors.push( | ||||||||||||||||||||||
| t.rich("stepError1", { rangePortion: (max - min) / 2 }) | ||||||||||||||||||||||
| t.rich("stepError1", { maxOptions: MaxDiscreteOptionCount }) | ||||||||||||||||||||||
| ); | ||||||||||||||||||||||
|
Comment on lines
+201
to
204
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix off‑by‑one in discrete step validation (can allow 51 options). Line 201 allows 🛠️ Proposed fix- if (step != 0 && step < (max - min) / MaxDiscreteOptionCount) {
+ if (step != 0 && step < (max - min) / (MaxDiscreteOptionCount - 1)) {
current_errors.push(
t.rich("stepError1", { maxOptions: MaxDiscreteOptionCount })
);
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
@@ -230,7 +234,7 @@ const NumericQuestionInput: React.FC<{ | |||||||||||||||||||||
| if (questionType === QuestionType.Discrete) { | ||||||||||||||||||||||
| inboundOutcomeCount = Math.max( | ||||||||||||||||||||||
| 3, | ||||||||||||||||||||||
| Math.min(200, Math.round((mx - mn) / step)) | ||||||||||||||||||||||
| Math.min(MaxDiscreteOptionCount, Math.round((mx - mn) / step)) | ||||||||||||||||||||||
| ); | ||||||||||||||||||||||
| } else { | ||||||||||||||||||||||
| inboundOutcomeCount = DefaultInboundOutcomeCount; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be pedantic, but this limit is about the number of in-bound outcomes, not total outcomes.
If we have 50 inbound outcomes, there is 1 more per open boundary.