2022-03-30 16:53:22 +00:00
|
|
|
import fs from "fs";
|
|
|
|
|
2022-04-01 20:24:35 +00:00
|
|
|
import { hash } from "../utils/hash";
|
2022-03-30 16:53:22 +00:00
|
|
|
import { Platform } from "./";
|
|
|
|
|
2022-04-01 20:24:35 +00:00
|
|
|
const platformName = "xrisk";
|
|
|
|
|
2022-03-30 16:53:22 +00:00
|
|
|
export const xrisk: Platform = {
|
|
|
|
name: "xrisk",
|
2022-04-01 20:24:35 +00:00
|
|
|
label: "X-risk estimates",
|
|
|
|
color: "#272600",
|
2022-03-30 16:53:22 +00:00
|
|
|
async fetcher() {
|
2022-04-01 20:24:35 +00:00
|
|
|
// return; // not necessary to refill the DB every time
|
2022-03-30 16:53:22 +00:00
|
|
|
let fileRaw = fs.readFileSync("./input/xrisk-questions.json", {
|
|
|
|
encoding: "utf-8",
|
|
|
|
});
|
2022-04-01 20:24:35 +00:00
|
|
|
let results = JSON.parse(fileRaw);
|
|
|
|
results = results.map((item) => ({
|
|
|
|
...item,
|
|
|
|
id: `${platformName}-${hash(item.title + " | " + item.url)}`, // some titles are non-unique, but title+url pair is always unique
|
|
|
|
platform: platformName,
|
|
|
|
}));
|
2022-03-30 16:53:22 +00:00
|
|
|
return results;
|
|
|
|
},
|
|
|
|
};
|