impr: allow low accuracy scores to be submitted if opted out of leaderboards

This commit is contained in:
Miodec 2023-10-27 14:17:20 +01:00
parent e3ce7b2458
commit 47c8668069
3 changed files with 13 additions and 2 deletions

View file

@ -150,6 +150,12 @@ export async function addResult(
//todo add a type here
const result = Object.assign({}, req.body.result);
if (!user.lbOptOut && result.acc < 75) {
throw new MonkeyError(
400,
"Cannot submit a result with less than 75% accuracy"
);
}
result.uid = uid;
if (isTestTooShort(result)) {
const status = MonkeyStatusCodes.TEST_TOO_SHORT;

View file

@ -2,7 +2,7 @@ import joi from "joi";
const RESULT_SCHEMA = joi
.object({
acc: joi.number().min(75).max(100).required(),
acc: joi.number().min(50).max(100).required(),
afkDuration: joi.number().min(0).required(),
bailedOut: joi.boolean().required(),
blindMode: joi.boolean().required(),

View file

@ -1065,7 +1065,12 @@ export async function finish(difficultyFailed = false): Promise<void> {
Notifications.add("Test invalid - raw", 0);
TestStats.setInvalid();
dontSave = true;
} else if (completedEvent.acc < 75 || completedEvent.acc > 100) {
} else if (
(!DB.getSnapshot()?.lbOptOut &&
(completedEvent.acc < 75 || completedEvent.acc > 100)) ||
(DB.getSnapshot()?.lbOptOut === true &&
(completedEvent.acc < 50 || completedEvent.acc > 100))
) {
Notifications.add("Test invalid - accuracy", 0);
TestStats.setInvalid();
dontSave = true;