fix: handle empty metaculus prediction
This commit is contained in:
parent
2345b81350
commit
646397d8d4
|
@ -49,7 +49,8 @@ const predictableProps = {
|
||||||
community_prediction: {
|
community_prediction: {
|
||||||
properties: {
|
properties: {
|
||||||
full: {
|
full: {
|
||||||
properties: {
|
// q1/q2/q3 can be missing, e.g. https://www.metaculus.com/api2/questions/1633/
|
||||||
|
optionalProperties: {
|
||||||
q1: {
|
q1: {
|
||||||
type: "float64",
|
type: "float64",
|
||||||
},
|
},
|
||||||
|
|
|
@ -38,7 +38,8 @@ async function apiQuestionToFetchedQuestions(
|
||||||
const isBinary = q.possibilities.type === "binary";
|
const isBinary = q.possibilities.type === "binary";
|
||||||
let options: FetchedQuestion["options"] = [];
|
let options: FetchedQuestion["options"] = [];
|
||||||
if (isBinary) {
|
if (isBinary) {
|
||||||
const probability = Number(q.community_prediction.full.q2);
|
const probability = q.community_prediction.full.q2;
|
||||||
|
if (probability !== undefined) {
|
||||||
options = [
|
options = [
|
||||||
{
|
{
|
||||||
name: "Yes",
|
name: "Yes",
|
||||||
|
@ -52,6 +53,7 @@ async function apiQuestionToFetchedQuestions(
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
id: `${platformName}-${q.id}`,
|
id: `${platformName}-${q.id}`,
|
||||||
options,
|
options,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user