mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-27 17:27:32 +08:00
impr: allow low accuracy scores to be submitted if opted out of leaderboards
This commit is contained in:
parent
e3ce7b2458
commit
47c8668069
3 changed files with 13 additions and 2 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue