Show progress while processing albums

Signed-off-by: James Ketrenos <james_git@ketrenos.com>
This commit is contained in:
James Ketr 2018-09-28 01:05:13 -07:00
parent 8f16c0337c
commit dd329dfd75

View File

@ -663,8 +663,15 @@ module.exports = {
* Operating in parallel could result in a child being searched for prior to the parent */ * Operating in parallel could result in a child being searched for prior to the parent */
now = Date.now(); now = Date.now();
let toProcess = albums.length, lastMessage = moment();
return Promise.mapSeries(albums, function(album) { return Promise.mapSeries(albums, function(album) {
return findOrCreateDBAlbum(album); return findOrCreateDBAlbum(album).then(function() {
toProcess--;
if (moment().add(-5, 'seconds') > lastMessage) {
console.log("Albums to be created in DB: " + toProcess);
lastMessage = moment();
}
});
}).then(function() { }).then(function() {
console.log("Processed " + albums.length + " album DB entries in " + console.log("Processed " + albums.length + " album DB entries in " +
((Date.now() - now) / 1000) + "s"); ((Date.now() - now) / 1000) + "s");