From 3892db1157c3be0d400f238485211522ee950b4d Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Thu, 28 Jul 2022 14:04:14 -0400 Subject: [PATCH] feat: save Insight Prediction progress Note that the fetcher is subject to this bug: which means that it'll hit insight pretty hard. --- src/backend/platforms/insight.ts | 33 ++++++++----------- .../QuestionCard/QuestionFooter.tsx | 2 +- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/backend/platforms/insight.ts b/src/backend/platforms/insight.ts index ee5886b..f942afb 100644 --- a/src/backend/platforms/insight.ts +++ b/src/backend/platforms/insight.ts @@ -65,7 +65,7 @@ async function fetchData(bearer: string) { console.log(`Page = #${pageNum}`); // console.log(newPageData) - console.dir(finalObject, {depth: null}); + // console.dir(finalObject, {depth: null}); results.push(... finalObject); let newPagination = newPage.meta.pagination; @@ -79,35 +79,30 @@ async function fetchData(bearer: string) { } async function processPredictions(predictions: any[]) { - let results = await predictions.map((prediction) => { + let filteredPredictions = predictions.filter(prediction => !prediction.is_resolved && prediction.category != "Sports") + let results = filteredPredictions.map((prediction) => { const id = `${platformName}-${ prediction.id }`; - const probability = prediction.probability; - const options: FetchedQuestion["options"] = [ - { - name: "Yes", - probability: probability, - type: "PROBABILITY" - }, { - name: "No", - probability: 1 - probability, - type: "PROBABILITY" - }, - ]; + const options: FetchedQuestion["options"] = prediction.options const result: FetchedQuestion = { id, title: prediction.title, - url: "https://example.com", - description: prediction.description, + url: `https:${ + prediction.url + }`, + description: prediction.rules, options, qualityindicators: { + volume: prediction.volume, + createdTime: prediction.created_at // other: prediction.otherx, // indicators: prediction.indicatorx, } }; return result; }); + // Filter results return results; // resultsProcessed } @@ -117,12 +112,12 @@ export const insight: Platform = { name: platformName, label: "Insight Prediction", color: "#ff0000", - version: "v0", + version: "v1", async fetcher() { let bearer = process.env.INSIGHT_BEARER; let data = await fetchData(bearer); - // console.log(data); - let results = []; // await processPredictions(data); // somehow needed + let results = await processPredictions(data); + console.log(results); return results; }, calculateStars(data) { diff --git a/src/web/questions/components/QuestionCard/QuestionFooter.tsx b/src/web/questions/components/QuestionCard/QuestionFooter.tsx index e60badb..837be7c 100644 --- a/src/web/questions/components/QuestionCard/QuestionFooter.tsx +++ b/src/web/questions/components/QuestionCard/QuestionFooter.tsx @@ -74,7 +74,7 @@ const getCurrencySymbolIfNeeded = ({ "openInterest", "liquidity", ]; - let dollarPlatforms = ["predictit", "kalshi", "polymarket"]; + let dollarPlatforms = ["predictit", "kalshi", "polymarket", "insight"]; if (indicatorsWhichNeedCurrencySymbol.includes(indicator)) { if (dollarPlatforms.includes(platform)) { return "$";