Skip to content

Commit

Permalink
Merge pull request #1 from ThEditor/master
Browse files Browse the repository at this point in the history
feat: new modes for club expo
  • Loading branch information
mradigen authored Jul 28, 2024
2 parents eaa766f + 9e32725 commit 3276a08
Show file tree
Hide file tree
Showing 42 changed files with 683 additions and 169 deletions.
3 changes: 3 additions & 0 deletions backend/src/api/controllers/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ async function updateUser(uid: string): Promise<void> {
words: {},
zen: {},
quote: {},
easy: {},
medium: {},
onerandom: {},
};
const modes = stats.map((it) => it["_id"]);
for (const mode of modes) {
Expand Down
3 changes: 3 additions & 0 deletions backend/src/api/controllers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,9 @@ export async function getUser(
quote: {},
zen: {},
custom: {},
easy: {},
medium: {},
onerandom: {},
};

const agentLog = buildAgentLog(req);
Expand Down
11 changes: 10 additions & 1 deletion backend/src/api/routes/leaderboards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,16 @@ const BASE_LEADERBOARD_VALIDATION_SCHEMA = {
.required(),
mode: joi
.string()
.valid("time", "words", "quote", "zen", "custom")
.valid(
"time",
"words",
"quote",
"zen",
"custom",
"easy",
"medium",
"onerandom"
)
.required(),
mode2: joi
.string()
Expand Down
11 changes: 10 additions & 1 deletion backend/src/api/routes/public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@ const GET_MODE_STATS_VALIDATION_SCHEMA = {
.required(),
mode: joi
.string()
.valid("time", "words", "quote", "zen", "custom")
.valid(
"time",
"words",
"quote",
"zen",
"custom",
"easy",
"medium",
"onerandom"
)
.required(),
mode2: joi
.string()
Expand Down
22 changes: 20 additions & 2 deletions backend/src/api/routes/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,16 @@ router.patch(
body: {
mode: joi
.string()
.valid("time", "words", "quote", "zen", "custom")
.valid(
"time",
"words",
"quote",
"zen",
"custom",
"easy",
"medium",
"onerandom"
)
.required(),
mode2: joi
.string()
Expand Down Expand Up @@ -434,7 +443,16 @@ router.get(
query: {
mode: joi
.string()
.valid("time", "words", "quote", "zen", "custom")
.valid(
"time",
"words",
"quote",
"zen",
"custom",
"easy",
"medium",
"onerandom"
)
.required(),
mode2: joi.string().regex(/^(\d)+|custom|zen/),
},
Expand Down
13 changes: 12 additions & 1 deletion backend/src/api/schemas/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,18 @@ const CONFIG_SCHEMA = joi.object({
numbers: joi.boolean(),
words: joi.number().min(0),
time: joi.number().min(0),
mode: joi.string().valid("time", "words", "quote", "zen", "custom"),
mode: joi
.string()
.valid(
"time",
"words",
"quote",
"zen",
"custom",
"easy",
"medium",
"onerandom"
),
quoteLength: joi.array().items(joi.number()),
language: joi
.string()
Expand Down
3 changes: 3 additions & 0 deletions backend/src/api/schemas/filter-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ const FILTER_SCHEMA = {
quote: joi.bool().required(),
zen: joi.bool().required(),
custom: joi.bool().required(),
easy: joi.bool().required(),
medium: joi.bool().required(),
onerandom: joi.bool().required(),
})
.required(),
words: joi
Expand Down
11 changes: 10 additions & 1 deletion backend/src/api/schemas/result-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,16 @@ const RESULT_SCHEMA = joi
lazyMode: joi.boolean().required(),
mode: joi
.string()
.valid("time", "words", "quote", "zen", "custom")
.valid(
"time",
"words",
"quote",
"zen",
"custom",
"easy",
"medium",
"onerandom"
)
.required(),
mode2: joi
.string()
Expand Down
24 changes: 24 additions & 0 deletions backend/src/dal/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ export async function addUser(
quote: {},
zen: {},
custom: {},
easy: {},
medium: {},
onerandom: {},
},
testActivity: {},
};
Expand Down Expand Up @@ -85,6 +88,9 @@ export async function resetUser(uid: string): Promise<void> {
quote: {},
zen: {},
custom: {},
easy: {},
medium: {},
onerandom: {},
},
lbPersonalBests: {
time: {},
Expand Down Expand Up @@ -170,6 +176,9 @@ export async function clearPb(uid: string): Promise<void> {
quote: {},
zen: {},
custom: {},
easy: {},
medium: {},
onerandom: {},
},
lbPersonalBests: {
time: {},
Expand Down Expand Up @@ -344,6 +353,9 @@ export async function addTag(
quote: {},
zen: {},
custom: {},
easy: {},
medium: {},
onerandom: {},
},
};

Expand Down Expand Up @@ -403,6 +415,9 @@ export async function removeTagPb(uid: string, _id: string): Promise<void> {
quote: {},
zen: {},
custom: {},
easy: {},
medium: {},
onerandom: {},
},
},
},
Expand Down Expand Up @@ -447,6 +462,9 @@ export async function checkIfPb(
quote: {},
words: {},
zen: {},
easy: {},
medium: {},
onerandom: {},
};
user.lbPersonalBests ??= {
time: {},
Expand Down Expand Up @@ -505,6 +523,9 @@ export async function checkIfTagPb(
quote: {},
zen: {},
custom: {},
easy: {},
medium: {},
onerandom: {},
};

const tagpb = checkAndUpdatePb(tag.personalBests, undefined, result);
Expand All @@ -531,6 +552,9 @@ export async function resetPb(uid: string): Promise<void> {
quote: {},
zen: {},
custom: {},
easy: {},
medium: {},
onerandom: {},
},
},
},
Expand Down
5 changes: 4 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
],
"devDependencies": {
"@fortawesome/fontawesome-free": "5.15.4",
"@monkeytype/shared-types": "*",
"@monkeytype/eslint-config": "*",
"@monkeytype/shared-types": "*",
"@monkeytype/typescript-config": "*",
"@types/canvas-confetti": "1.4.3",
"@types/chartjs-plugin-trendline": "1.0.1",
Expand Down Expand Up @@ -97,5 +97,8 @@
"madge": {
"@typescript-eslint/typescript-estree": "7.1.0"
}
},
"optionalDependencies": {
"@rollup/rollup-linux-x64-gnu": "4.19.1"
}
}
3 changes: 3 additions & 0 deletions frontend/src/html/pages/account.html
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,9 @@
<button filter="quote">quote</button>
<button filter="zen">zen</button>
<button filter="custom">custom</button>
<button filter="easy">easy</button>
<button filter="medium">medium</button>
<button filter="onerandom">onerandom</button>
</div>
</div>
<div class="buttonsAndTitle">
Expand Down
12 changes: 12 additions & 0 deletions frontend/src/html/pages/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@
<i class="fas fa-fw fa-wrench"></i>
custom
</button>
<button class="textButton" mode="easy">
<i class="fas fa-fw fa-leaf"></i>
easy
</button>
<button class="textButton" mode="medium">
<i class="fas fa-fw fa-leaf"></i>
medium
</button>
<button class="textButton" mode="onerandom">
<i class="fas fa-fw fa-leaf"></i>
onerandom
</button>
</div>

<div class="spacer rightSpacer"></div>
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/html/popups.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@
<label class="checkboxWithSub mode">
<input type="checkbox" setting="mode" />
<div>Mode</div>
<div class="sub">Time, Words, Quote, Zen, Custom</div>
<div class="sub">
Time, Words, Quote, Zen, Custom, Easy, Medium, OneRandom
</div>
</label>
<label class="checkboxWithSub mode2 subgroup hidden">
<input type="checkbox" setting="mode2" />
Expand Down Expand Up @@ -204,6 +206,9 @@
<button data-mode="quote">quote</button>
<button data-mode="zen">zen</button>
<button data-mode="custom">custom</button>
<button data-mode="easy">easy</button>
<button data-mode="medium">medium</button>
<button data-mode="onerandom">onerandom</button>
</div>
<div class="group timeGroup">
<button data-time="15">15</button>
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/ts/commandline/lists/bail-out.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ function canBailOut(): boolean {
CustomText.getLimitMode() === "time" &&
(CustomText.getLimitValue() >= 3600 ||
CustomText.getLimitValue() === 0)) ||
(Config.mode === "words" && Config.words >= 5000) ||
((Config.mode === "words" || Config.mode === "easy") &&
Config.words >= 5000) ||
Config.words === 0 ||
(Config.mode === "time" && (Config.time >= 3600 || Config.time === 0)) ||
Config.mode === "zen"
Expand Down
28 changes: 28 additions & 0 deletions frontend/src/ts/commandline/lists/mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,34 @@ const commands: MonkeyTypes.Command[] = [
TestLogic.restart();
},
},
{
id: "changeModeEasy",
display: "easy",
configValue: "easy",
exec: (): void => {
UpdateConfig.setMode("easy");
UpdateConfig.setWordCount(10);
TestLogic.restart();
},
},
{
id: "changeModeMedium",
display: "medium",
configValue: "medium",
exec: (): void => {
UpdateConfig.setMode("medium");
TestLogic.restart();
},
},
{
id: "changeModeOneRandom",
display: "onerandom",
configValue: "onerandom",
exec: (): void => {
UpdateConfig.setMode("onerandom");
TestLogic.restart();
},
},
],
},
},
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/ts/commandline/lists/quote-favorites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const commands: MonkeyTypes.Command[] = [
return (
isAuthenticated() &&
quote !== null &&
Config.mode === "quote" &&
(Config.mode === "quote" || Config.mode === "medium") &&
!QuotesController.isQuoteFavorite(quote)
);
},
Expand Down Expand Up @@ -48,7 +48,7 @@ const commands: MonkeyTypes.Command[] = [
return (
isAuthenticated() &&
quote !== null &&
Config.mode === "quote" &&
(Config.mode === "quote" || Config.mode === "medium") &&
QuotesController.isQuoteFavorite(quote)
);
},
Expand Down
Loading

0 comments on commit 3276a08

Please sign in to comment.