Skip to content

Commit

Permalink
feat: add timer and improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
wldeh committed May 8, 2023
1 parent 172cd6b commit 68550ed
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default async function main(): Promise<void> {

for await (const item of array) {
count++
console.log(`(${count / array.length}) Setting up: ${item[4]}`)
console.log(`(${count + '/' + array.length}) Setting up: ${item[4]}`)
await setupBible(
`https://app.thedigitalbiblelibrary.org/entry?id=${item[0]}`
)
Expand All @@ -28,11 +28,16 @@ export default async function main(): Promise<void> {

async function setupBible(url: string): Promise<void> {
try {
const startTime = performance.now()
const outPath = `./${Math.random().toString(36).substring(2)}`

await Importer.importFolder(url, outPath)
await Directory.createDirs(outPath)
await Content.populate(outPath)

const endTime = performance.now()
const timeTaken = endTime - startTime
console.log(`Finished In ${(timeTaken / 1000).toFixed(2)} seconds @ ${new Date().toLocaleString('en-US', {timeZone: 'America/Los_Angeles'})}}`)
} catch (error) {
console.error(`Error setting up Bible: ${error.message}`)
}
Expand Down

0 comments on commit 68550ed

Please sign in to comment.