feat: add requests progress bar
Signed-off-by: Dmytro Stanchiev <git@dmytros.dev>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import { parseHTML } from "linkedom";
|
||||
import unidecode from "unidecode";
|
||||
import cliProgress from "cli-progress";
|
||||
|
||||
// const unidecode = require("unidecode");
|
||||
|
||||
@@ -348,6 +349,14 @@ export default async function fetchKijijiItems(
|
||||
`Found ${listingLinks.length} listing links. Fetching details...`,
|
||||
);
|
||||
|
||||
const progressBar = new cliProgress.SingleBar(
|
||||
{},
|
||||
cliProgress.Presets.shades_classic,
|
||||
);
|
||||
const totalProgress = listingLinks.length;
|
||||
let currentProgress = 0;
|
||||
progressBar.start(totalProgress, currentProgress);
|
||||
|
||||
const items: ListingDetails[] = [];
|
||||
for (const link of listingLinks) {
|
||||
try {
|
||||
@@ -372,6 +381,9 @@ export default async function fetchKijijiItems(
|
||||
`Failed to fetch ${link} - ${String((err as Error)?.message || err)}`,
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
currentProgress++;
|
||||
progressBar.update(currentProgress);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user