fix: weird problem with GiveWell dates

This commit is contained in:
NunoSempere 2022-02-14 15:39:30 -05:00
parent 927114a8cc
commit 752a5b2cfe
3 changed files with 18 additions and 7 deletions

View File

@ -324,7 +324,7 @@ export async function pgInsertIntoDashboard({ datum, schema, tableName }) {
creator text, creator text,
extra json extra json
*/ */
/*
pgInsertIntoDashboard({ pgInsertIntoDashboard({
datum: { datum: {
title: "Test dashboard", title: "Test dashboard",
@ -341,7 +341,7 @@ pgInsertIntoDashboard({
schema: "latest", schema: "latest",
tableName: "dashboards", tableName: "dashboards",
}); });
*/
export async function pgUpsert({ contents, schema, tableName }) { export async function pgUpsert({ contents, schema, tableName }) {
if (tableWhiteList.includes(`${schema}.${tableName}`)) { if (tableWhiteList.includes(`${schema}.${tableName}`)) {
if (schema == "latest") { if (schema == "latest") {

View File

@ -16,7 +16,7 @@
"probability": 0.75, "probability": 0.75,
"type": "PROBABILITY" "type": "PROBABILITY"
} }
], ],
"timestamp": "2021-02-23T152137.005Z", "timestamp": "2021-02-23T152137.005Z",
"qualityindicators": { "qualityindicators": {
"stars": 2 "stars": 2

View File

@ -23,7 +23,7 @@ async function fetchPage(url) {
/* Body */ /* Body */
async function main() { async function main1() {
let rawdata = fs.readFileSync("./src/input/givewellopenphil-urls.txt"); let rawdata = fs.readFileSync("./src/input/givewellopenphil-urls.txt");
let data = rawdata let data = rawdata
.toString() .toString()
@ -64,7 +64,18 @@ async function main() {
} }
// let string = JSON.stringify(results, null, 2) // let string = JSON.stringify(results, null, 2)
// fs.writeFileSync('./data/givewell-questions-unprocessed.json', string); // fs.writeFileSync('./data/givewell-questions-unprocessed.json', string);
await databaseUpsert({ contents: results, group: "givewell-questions-unprocessed" }); await databaseUpsert({
contents: results,
group: "givewell-questions-unprocessed",
});
} }
main(); // main1()
async function main2() {
let rawdata = fs.readFileSync("./src/input/givewellopenphil-questions.json");
let data = JSON.parse(rawdata);
let dataWithDate = data.map(datum => ({...datum, timestamp: '2021-02-23'}))
await databaseUpsert({ group: "givewellopenphil", contents: dataWithDate });
}
main2();