Skip to content

Commit

Permalink
feat: display total elapsed time (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
kptdobe authored Feb 1, 2023
1 parent dd86c58 commit a7ea2d9
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion js/import/import.ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,17 @@ const updateImporterUI = (results, originalURL) => {
li.append(icon);

BULK_URLS_LIST.append(li);
BULK_URLS_HEADING.innerText = `Imported URLs (${importStatus.imported} / ${importStatus.total}):`;

const totalTime = Math.round((new Date() - importStatus.startTime) / 1000);
let timeStr = `${totalTime}s`;
if (totalTime > 60) {
timeStr = `${Math.round(totalTime / 60)}m ${totalTime % 60}s`;
if (totalTime > 3600) {
timeStr = `${Math.round(totalTime / 3600)}h ${Math.round((totalTime % 3600) / 60)}m`;
}
}

BULK_URLS_HEADING.innerText = `Imported URLs (${importStatus.imported} / ${importStatus.total}) - Elapsed time: ${timeStr}`;
}
};

Expand All @@ -150,6 +160,7 @@ const clearResultPanel = () => {
};

const initImportStatus = () => {
importStatus.startTime = 0;
importStatus.imported = 0;
importStatus.total = 0;
importStatus.rows = [];
Expand Down Expand Up @@ -303,6 +314,7 @@ const attachListeners = () => {
const field = IS_BULK ? 'import-urls' : 'import-url';
const urlsArray = config.fields[field].split('\n').reverse().filter((u) => u.trim() !== '');
importStatus.total = urlsArray.length;
importStatus.startTime = Date.now();
const processNext = async () => {
if (urlsArray.length > 0) {
const url = urlsArray.pop();
Expand Down

0 comments on commit a7ea2d9

Please sign in to comment.