From 29fb2351a38eb15321b780a9e74144240eacbb2b Mon Sep 17 00:00:00 2001 From: "Jonathan R. Warden" Date: Mon, 17 Jun 2024 14:05:12 -0600 Subject: [PATCH] Tweak to 'just import-society-library': default args, output root post id for debate --- justfile | 4 ++-- other/import-society-library-debatemap.ts | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/justfile b/justfile index 9738100a..6e0f68f6 100644 --- a/justfile +++ b/justfile @@ -59,8 +59,8 @@ reseed: import-hn: npx tsx import-hn.ts ./other/hn-data/*.json.gz -import-society-library json userid: - npx tsx other/import-society-library-debatemap.ts {{json}} {{userid}} +import-society-library json="other/society-library-openai-debatemap.json" username="developer": + npx tsx other/import-society-library-debatemap.ts {{json}} {{username}} # delete local database, download production database download-prod-db: diff --git a/other/import-society-library-debatemap.ts b/other/import-society-library-debatemap.ts index 586e5f6a..ed98f3a2 100644 --- a/other/import-society-library-debatemap.ts +++ b/other/import-society-library-debatemap.ts @@ -33,7 +33,9 @@ const userId = await db.transaction().execute(async trx => { console.log('Got debate map for question', topLevelQuestion) -await importQuestion(topLevelQuestion) +const postId = await importQuestion(topLevelQuestion) + +console.log('Imported debate map. Root post-id = ', postId) // type Node = Question | Category | Claim @@ -70,7 +72,7 @@ function removePrefix(wording: string, prefix: string) { return wording } -async function importQuestion(question: Question) { +async function importQuestion(question: Question): Promise { let wording = removePrefix(question.question, '[question] ') const postId = await db.transaction().execute(async trx => { @@ -84,6 +86,8 @@ async function importQuestion(question: Question) { for (const position of question.positions) { await importPosition(postId, position) } + + return postId } async function importPosition(parentId: number, position: Position) {