Made small change to xriskdatabase, and prepared for the creation of a history database

This commit is contained in:
NunoSempere 2021-04-10 12:11:47 +02:00
parent 9d0517137d
commit 0ae360a1d7
6 changed files with 2409 additions and 192 deletions

View File

@ -2,6 +2,11 @@
"title": "Some title",
"url": "someurl.com",
"platform": "some platform",
"description": "Some long description which may contain html",
"moreoriginsdata": {
"author": "Field may not exist",
"contractAddress": "Field may not exist"
},
"options": [
{
"name": "Option 1",
@ -19,8 +24,11 @@
"type": "PROBABILITY"
}
],
"description": "Some long description which may contain html",
"numforecasts": 15,
"stars": 2
"qualityindicators": {
"numforecasts": "137",
"liquidity": "1585.76",
"tradevolume": "9977.68",
"stars": 3
}
}
]

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,25 @@
import { mongoRead, upsert } from "./mongo-wrapper.js"
let createInitialHistory = async () => {
let metaforecasts = await mongoRead("metaforecasts")
let metaforecastsHistorySeed = metaforecasts.map(element => {
// let moreoriginsdata = element.author ? ({author: element.author}) : ({})
return ({
title: element.title,
url: element.url,
platform: element.platform,
moreoriginsdata: element.moreoriginsdata || {},
description: element.description,
history: [{
timestamp: element.timestamp,
options: element.options,
qualityindicators: element.qualityindicators
}],
extra: element.extra || {}
})
})
console.log(metaforecastsHistorySeed)
await upsert(metaforecastsHistorySeed, "metaforecast_history")
}
createInitialHistory()

View File

@ -0,0 +1,31 @@
/* Imports */
import fs from "fs"
/* Definitions */
let locationData = "../../data/"
/* Body */
let rawdata = fs.readFileSync("/home/nuno/Documents/core/software/fresh/js/metaforecasts/metaforecasts-mongo/src/input/xrisk-questions.json")
let data = JSON.parse(rawdata)
let results = []
for(let datum of data){
let result = ({
"title": datum["title"],
"url": datum["url"],
"platform": "X-risk estimates",
"moreoriginsdata": {
"author": datum.author,
},
"description": datum.description,
"options": datum.options,
"timestamp": datum.timestamps,
"qualityindicators": {
"stars": 2//datum["stars"]
}
})
results.push(result)
}
let string = JSON.stringify(results,null, 2)
fs.writeFileSync("/home/nuno/Documents/core/software/fresh/js/metaforecasts/metaforecasts-mongo/src/input/xrisk-questions-new2.json", string)

View File

@ -1,9 +0,0 @@
let sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms))
let loop = async () => {
for (let i = 0; i < 6; i++) {
console.log(i)
await sleep(1000)
}
}
loop()