diff --git a/src/helper/requests.js b/src/helper/requests.js index 85a93cd..d5d6c40 100644 --- a/src/helper/requests.js +++ b/src/helper/requests.js @@ -77,6 +77,7 @@ export function cycleStatus(cycle) { processed: [], failed: [], }; + for (let i = 0; i < cycle.length; i += 1) { const opts = cycle[i]; if (opts.data) { @@ -86,6 +87,22 @@ export function cycleStatus(cycle) { status.failed.push(opts) } } + + // get usernames in status.failed + const usernames = status.failed.map((opts) => opts.username); + const uniqueFailedUsernames = [...new Set(usernames)]; + let actuallyProccessed = []; + for (let i = 0; i < status.processed.length; i += 1) { + const opts = status.processed[i]; + if (!uniqueFailedUsernames.includes(opts.username)) { + actuallyProccessed.push(opts); + } + else { + status.failed.push(opts); + } + } + + status.processed = actuallyProccessed; return status; } diff --git a/src/requests/index.js b/src/requests/index.js index 8c14eb7..61eea52 100644 --- a/src/requests/index.js +++ b/src/requests/index.js @@ -69,7 +69,7 @@ export default class Requests { const timeTaken = Date.now() - start; const percentageOnTarget = (cycleLength * 500 * 60) / timeTaken; const timePerRoom = (Date.now() - start) / cycleLength - UploadStatus({ amountPerCycle: cycleLength, timePerRoom, percentageOnTarget, timeTaken }) + UploadStatus({ cycleDetails: { amount: cycleLength, success: status.processed.length, failed: status.failed.length, successRate: Math.round((status.processed.length / cycleLength) * 100) }, timePerRoom, percentageOnTarget, timeTaken }) } this.executeCycle(); }