metaforecast/src/backend/utils/evaluations/pullForecastsToCSVForRating.js
Vyacheslav Matyukhin b481212721
feat: more ts, fix tailwind
- rename more files to .ts/.tsx
- update tailwind config to use .tsx files from all dirs
- merge css files into a single main.css to avoid import order
  dependencies
- minor cleanups due to ts complaints
2022-03-26 03:36:50 +03:00

51 lines
1.3 KiB
JavaScript

/* Imports */
import fs from "fs";
import { databaseReadWithReadCredentials } from "../database-wrapper";
/* Definitions */
/* Utilities */
/* Support functions */
let getQualityIndicators = (forecast) =>
Object.entries(forecast.qualityindicators)
.map((entry) => `${entry[0]}: ${entry[1]}`)
.join("; ");
/* Body */
let main = async () => {
let highQualityPlatforms = [
"CSET-foretell",
"Foretold",
"Good Judgment Open",
"Metaculus",
"PredictIt",
"Rootclaim",
];
let json = await databaseReadWithReadCredentials({ group: "combined" });
console.log(json.length);
//let uniquePlatforms = [...new Set(json.map(forecast => forecast.platform))]
//console.log(uniquePlatforms)
let forecastsFromGoodPlatforms = json.filter((forecast) =>
highQualityPlatforms.includes(forecast.platform)
);
let tsv =
"index\ttitle\turl\tqualityindicators\n" +
forecastsFromGoodPlatforms
.map((forecast, index) => {
let row = `${index}\t${forecast.title}\t${
forecast.url
}\t${getQualityIndicators(forecast)}`;
console.log(row);
return row;
})
.join("\n");
//console.log(tsv)
// let string = JSON.stringify(json, null, 2)
fs.writeFileSync("metaforecasts.tsv", tsv);
};
main();