Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/src/api/controllers/result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ export async function addResult(
}

if (req.ctx.configuration.users.lastHashesCheck.enabled) {
let lastHashes = user.lastReultHashes ?? [];
let lastHashes = user.lastResultHashes ?? user.lastReultHashes ?? [];
if (lastHashes.includes(resulthash)) {
void addLog(
"duplicate_result",
Expand Down
6 changes: 4 additions & 2 deletions backend/src/api/controllers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,8 @@ type RelevantUserInfo = Omit<
| "nameHistory"
| "lastNameChange"
| "_id"
| "lastReultHashes" //TODO fix typo
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is obsolete when we move the property to the DBUser

| "lastResultHashes"
| "lastReultHashes"
| "note"
| "ips"
| "testActivity"
Expand All @@ -524,7 +525,8 @@ function getRelevantUserInfo(user: UserDAL.DBUser): RelevantUserInfo {
"nameHistory",
"lastNameChange",
"_id",
"lastReultHashes", //TODO fix typo
"lastResultHashes",
"lastReultHashes",
"note",
"ips",
"testActivity",
Expand Down
5 changes: 4 additions & 1 deletion backend/src/dal/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,10 @@ export async function updateLastHashes(
{ uid },
{
$set: {
lastReultHashes: lastHashes, //TODO fix typo
lastResultHashes: lastHashes,
},
$unset: {
lastReultHashes: 1,
},
},
);
Expand Down
3 changes: 2 additions & 1 deletion packages/schemas/src/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ export const UserSchema = z.object({
uid: z.string(), //defined by firebase, no validation should be applied
addedAt: z.number().int().nonnegative(),
personalBests: PersonalBestsSchema,
lastReultHashes: z.array(z.string()).optional(), //TODO: fix typo (it's in the db too)
lastResultHashes: z.array(z.string()).optional(),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lastResultHashes is not used on the frontend. We should just remove it here and move it to the DBUsertype.

lastReultHashes: z.array(z.string()).optional(), //legacy typo, kept for backwards compatibility
completedTests: z.number().int().nonnegative().optional(),
startedTests: z.number().int().nonnegative().optional(),
timeTyping: z
Expand Down
Loading