allowJs is set to false in tsconfig.json now; please write all future code with typescript. cleanups: - removed platforms/deprecated - removed flow/history/old - see https://github.com/QURIresearch/metaforecast/issues/22 - commented some invalid axios options - minor fixes with mismatching function arguments - commented invalid mongo call in databaseReadWithReadCredentials - {encoding: 'utf-8'} in readFileSync calls
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
/* Imports */
|
|
import fs from 'fs';
|
|
|
|
import { databaseReadWithReadCredentials } from '../../database/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();
|