fix: metaculus on groups

This commit is contained in:
Vyacheslav Matyukhin 2022-06-03 16:54:45 +03:00
parent 5bf24a58ef
commit ceeeff9681
No known key found for this signature in database
GPG Key ID: 3D2A774C5489F96C
2 changed files with 7 additions and 4 deletions

View File

@ -106,6 +106,9 @@ const questionSchema = {
properties: { properties: {
...commonProps, ...commonProps,
...pageProps, ...pageProps,
},
optionalProperties: {
...optionalPageProps,
sub_questions: { sub_questions: {
elements: { elements: {
properties: { properties: {
@ -116,9 +119,6 @@ const questionSchema = {
}, },
}, },
}, },
optionalProperties: {
...optionalPageProps,
},
additionalProperties: true, additionalProperties: true,
}, },
// we're not interested in claims currently (but we should be?) // we're not interested in claims currently (but we should be?)

View File

@ -74,7 +74,10 @@ async function apiQuestionToFetchedQuestions(
if (apiQuestion.type === "group") { if (apiQuestion.type === "group") {
await sleep(SLEEP_TIME); await sleep(SLEEP_TIME);
const apiQuestionDetails = await fetchSingleApiQuestion(apiQuestion.id); const apiQuestionDetails = await fetchSingleApiQuestion(apiQuestion.id);
return apiQuestion.sub_questions if (apiQuestionDetails.type !== "group") {
throw new Error("Expected `group` type"); // shouldn't happen, this is mostly for typescript
}
return (apiQuestionDetails.sub_questions || [])
.filter((q) => !skip(q)) .filter((q) => !skip(q))
.map((sq) => { .map((sq) => {
const tmp = buildFetchedQuestion(sq); const tmp = buildFetchedQuestion(sq);