Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
schpet committed Apr 10, 2024
1 parent cb34315 commit 41a5e3b
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/commands/dump.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ export default class Dump extends Command {
}>
>(`https://www.pivotaltracker.com/services/v5/projects/${projectId}/memberships`, async (page) => {
let people: Array<tracker.Person> = page.map((membership) => membership.person)
await db.insert(tracker.personTable).values(people)
if (people.length > 0) {
await db.insert(tracker.personTable).values(people)
}
})

type ApiStory = {
Expand Down Expand Up @@ -175,11 +177,13 @@ export default class Dump extends Command {
let storyResult = await db.insert(tracker.storyTable).values(page)
console.log(`added ${storyResult.changes} stories`)

await db.insert(tracker.blockerTable).values(
page.flatMap((story) => {
return story.blockers.map((blocker) => ({...blocker, story_id: story.id}))
}),
)
const blockers = page.flatMap((story) => {
return story.blockers.map((blocker) => ({...blocker, story_id: story.id}))
})

if (blockers.length > 0) {
await db.insert(tracker.blockerTable).values(blockers)
}

for (const story of page) {
// labels
Expand Down Expand Up @@ -269,7 +273,7 @@ export default class Dump extends Command {
email: `unknown-${id}@example.com`,
initials: '??',
username: `unknown-${id}`,
}))
})),
)
}
}
Expand Down

0 comments on commit 41a5e3b

Please sign in to comment.