Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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":

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not hardcode the filename here, it publishes too much information.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if I just change it to "debatemap.json"?

My motive here is that I want to use the justfile to remember command lines for common tasks. If I have to pass a lot of arguments to the justfile target, then I will end up creating another file to hold the 'just' commandline.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds good to me

npx tsx other/import-society-library-debatemap.ts {{json}} {{username}}

# delete local database, download production database
download-prod-db:
Expand Down
8 changes: 6 additions & 2 deletions other/import-society-library-debatemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -70,7 +72,7 @@ function removePrefix(wording: string, prefix: string) {
return wording
}

async function importQuestion(question: Question) {
async function importQuestion(question: Question): Promise<number> {
let wording = removePrefix(question.question, '[question] ')

const postId = await db.transaction().execute(async trx => {
Expand All @@ -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) {
Expand Down