From f7a324cce02f0c403c9ca78a487cb78fce1fbf9d Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Tue, 31 Aug 2021 21:23:08 +0200 Subject: [PATCH] feat: Deal with new CSET-Foretell question types. Per https://www.cset-foretell.com/blog/rolling-question-formats, CSET-Foretell has added new question types. They appear to be fairly hard to parse, so I'm not doing that yet. However, I'm still incorporating them into the database --- src/platforms/csetforetell-fetch.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/platforms/csetforetell-fetch.js b/src/platforms/csetforetell-fetch.js index c71ae8a..e06d272 100644 --- a/src/platforms/csetforetell-fetch.js +++ b/src/platforms/csetforetell-fetch.js @@ -85,11 +85,17 @@ async function fetchStats(questionUrl, cookie){ let optionsHtmlElement = "" let tablesAsJson = Tabletojson.convert(optionsHtmlElement) let firstTable = tablesAsJson[0] - options = firstTable.map(element => ({ - name: element['0'], - probability: Number(element['1'].replace("%",""))/100, - type: "PROBABILITY" - })) + if(firstTable){ + options = firstTable.map(element => ({ + name: element['0'], + probability: Number(element['1'].replace("%",""))/100, + type: "PROBABILITY" + })) + }else{ + // New type of question, tricky to parse the options + // Just leave options = [] for now. + // https://www.cset-foretell.com/blog/rolling-question-formats + } } }