Fix audit sync progress logging

This commit is contained in:
Mononaut 2023-06-20 17:07:14 -04:00
parent 736b997104
commit 7f6d17fc0e
No known key found for this signature in database
GPG Key ID: A3F058E41374C04E

View File

@ -37,10 +37,11 @@ class AuditReplication {
let loggerTimer = Date.now();
// process missing audits in batches of
for (let i = 0; i < missingAudits.length; i += BATCH_SIZE) {
const results = await Promise.all(missingAudits.slice(i * BATCH_SIZE, (i + 1) * BATCH_SIZE).map(hash => this.$syncAudit(hash)));
const slice = missingAudits.slice(i * BATCH_SIZE, (i + 1) * BATCH_SIZE);
const results = await Promise.all(slice.map(hash => this.$syncAudit(hash)));
const synced = results.reduce((total, status) => status ? total + 1 : total, 0);
totalSynced += synced;
totalMissed += (BATCH_SIZE - synced);
totalMissed += (slice.length - synced);
if (Date.now() - loggerTimer > 10000) {
loggerTimer = Date.now();
logger.info(`Found ${totalSynced} / ${totalSynced + totalMissed} of ${missingAudits.length} missing audits`, 'Replication');