Skip to content

Commit

Permalink
When user fails once, fail for all
Browse files Browse the repository at this point in the history
  • Loading branch information
pieterbrandsen authored Feb 5, 2024
1 parent 9a1d56b commit b76d1dc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/helper/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/requests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit b76d1dc

Please sign in to comment.