impr(backend): consider incomplete tests when checking result spacing

!nuf
This commit is contained in:
Miodec 2024-09-30 14:08:46 +02:00
parent 7ed56db4e0
commit 73f8022992

View file

@ -276,6 +276,8 @@ export async function addResult(
) {
const status = MonkeyStatusCodes.RESULT_DATA_INVALID;
throw new MonkeyError(status.code, "Result data doesn't make sense");
} else if (isDevEnvironment()) {
Logger.success("Result data validated");
}
} else {
if (!isDevEnvironment()) {
@ -311,7 +313,9 @@ export async function addResult(
//check if now is earlier than last result plus duration (-1 second as a buffer)
const testDurationMilis = completedEvent.testDuration * 1000;
const earliestPossible = (lastResultTimestamp ?? 0) + testDurationMilis;
const incompleteTestsMilis = completedEvent.incompleteTestSeconds * 1000;
const earliestPossible =
(lastResultTimestamp ?? 0) + testDurationMilis + incompleteTestsMilis;
const nowNoMilis = Math.floor(Date.now() / 1000) * 1000;
if (lastResultTimestamp && nowNoMilis < earliestPossible - 1000) {
void addLog(