From 1fd3b29def7fcc8bfc56319b67050ec2ede7507e Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Wed, 11 Aug 2021 22:01:31 +0200 Subject: [PATCH] fix: Cosmetic tweaks to Hypermind forecasts --- src/platforms/hypermind-fetch.js | 13 +++++++++---- src/utils/algolia.js | 6 ++++-- src/utils/toMarkdown.js | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/platforms/hypermind-fetch.js b/src/platforms/hypermind-fetch.js index 76016da..d5462ae 100644 --- a/src/platforms/hypermind-fetch.js +++ b/src/platforms/hypermind-fetch.js @@ -110,6 +110,7 @@ async function hypermind_inner(cookie) { "timestamp": new Date().toISOString(), "qualityindicators": { "stars": calculateStars("Hypermind", ({})), + // "numforecasters": res.fcsterCnt } }) }) @@ -120,7 +121,7 @@ async function hypermind_inner(cookie) { // Hypermind panelists and competitors; dashboard type two: "showcase" // https://prod.hypermind.com/ngdp/fr/showcase2/showcase.html?sc=SLUG // E.g., https://prod.hypermind.com/ngdp/fr/showcase2/showcase.html?sc=AI2023 - let slugs2 = [ "Covid19", "DOSES", "H5N8", "NGDP", "JSAI", "AI2023", "AI2030"] + let slugs2 = [ "Covid19" , "DOSES", "H5N8", "NGDP", "JSAI", "AI2023", "AI2030" ] let results2 = [] for(let slug of slugs2){ console.log(slug) @@ -129,16 +130,20 @@ async function hypermind_inner(cookie) { let objs = response.map(result => { let descriptionraw = result.props.details.split("
")[0] let descriptionprocessed1 = toMarkdown(descriptionraw) - let descriptionprocessed2 = descriptionprocessed1.split("![image]")[0] - let description = descriptionprocessed2 + let descriptionprocessed2 = descriptionprocessed1.replaceAll("![image] ()", "") + let descriptionprocessed3 = descriptionprocessed2.replaceAll(" Forecasting Schedule ", "") + let descriptionprocessed4 = descriptionprocessed3.replaceAll("\n", "") + let descriptionprocessed5 = descriptionprocessed4.replaceAll("Context: ", "") + let description = descriptionprocessed5 || toMarkdown(result.props.details) return ({ "title": result.props.title, - "url": "https://prod.hypermind.com/ngdp/en/showcase/showcase.html", + "url": "https://prod.hypermind.com/ngdp/fr/showcase2/showcase.html?sc="+slug, "platform": "Hypermind", "description": description, "options": [], "qualityindicators": { "stars": calculateStars("Hypermind", ({})), + "numforecasters": Number(result.fcsterCnt) } }) }) diff --git a/src/utils/algolia.js b/src/utils/algolia.js index 73c7800..7f86c78 100644 --- a/src/utils/algolia.js +++ b/src/utils/algolia.js @@ -10,7 +10,7 @@ const client = algoliasearch('96UD3NTQ7L', cookie); // delete this when committi const index = client.initIndex('metaforecast'); -export async function rebuildAlgoliaDatabase(){ +export async function rebuildAlgoliaDatabaseTheHardWay(){ console.log("Doing this the hard way") let records = await mergeEverythingInner() records = records.map((record, index) => ({...record, has_numforecasts: record.numforecasts ? true : false, objectID: index}) ) @@ -33,4 +33,6 @@ export async function rebuildAlgoliaDatabaseTheEasyWay(){ index.replaceAllObjects(records, { safe:true }).catch(error => console.log(error)) console.log(`Pushed ${records.length} records. Algolia will update asynchronously`) } -} \ No newline at end of file +} + +export const rebuildAlgoliaDatabase = rebuildAlgoliaDatabaseTheHardWay \ No newline at end of file diff --git a/src/utils/toMarkdown.js b/src/utils/toMarkdown.js index 3b2cf51..7493e53 100644 --- a/src/utils/toMarkdown.js +++ b/src/utils/toMarkdown.js @@ -18,4 +18,4 @@ export default function toMarkdown(htmlText){ return textVersion(htmlText, styleConfig); } -toMarkdown() +// toMarkdown()