Automattic/regenerate-thumbnails

Showing incorrect duration after running the regeneration

Opened this issue · 2 comments

There is an issue while showing the time duration after running the regeneration.

I tested and for a result in +1 minute, I had the following feedback:

Screen Shot 2020-06-24 at 11 58 03

A user reported that she had the feedback 0.6 minutes after ~30 minutes.

Probably the issue is here:

// If done, show how long it took
if (processed == totalItems) {
let secondsTaken = (Date.now() - startTime) / 1000;
let durationString = '';
if (secondsTaken > 3600) {
let hoursTaken = secondsTaken / 3600;
durationString = vue.regenerateThumbnails.l10n.RegenerateMultiple.hours.formatUnicorn({
count: hoursTaken.toFixed(1),
});
} else if (secondsTaken > 60) {
let minutesTaken = secondsTaken / 3600;
durationString = vue.regenerateThumbnails.l10n.RegenerateMultiple.minutes.formatUnicorn({
count: minutesTaken.toFixed(1),
});
} else {
durationString = vue.regenerateThumbnails.l10n.RegenerateMultiple.seconds.formatUnicorn({
count: secondsTaken.toFixed(),
});
}
vue.finishedMessage = vue.regenerateThumbnails.l10n.RegenerateMultiple.duration.formatUnicorn({
duration: durationString,
});
}

Hello, Can I work on this?

Hey @kunal13053!

Sure! Feel free to create a PR with the solution! It's always a pleasure to receive contributions from the community!