-
Notifications
You must be signed in to change notification settings - Fork 1
Add challenge lock, update logic for reviewer, copilot payments #88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
prisma/migrations/20251020100641_challenge-processing-lock/migration.sql
Show resolved
Hide resolved
| submissions.map((s) => [s.memberId, s]), | ||
| ); | ||
| return Object.keys(uniqueSubmissions).length; | ||
| const resposne = await this.m2MService.m2mFetch<{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[❗❗ correctness]
There is a typo in the variable name resposne. It should be response. This could lead to confusion and errors if the variable is referenced elsewhere.
| } | ||
|
|
||
| if (!copilots?.length) { | ||
| throw new Error('Task has a copilot prize but no copilot assigned!'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[💡 maintainability]
Throwing an error when there is a copilot prize but no copilot assigned is correct, but consider logging additional context about the challenge to aid in debugging.
| }); | ||
| const challengeReviews = await this.getChallengeReviews(challenge.id); | ||
|
|
||
| if (!challengeReviewer || !reviewers?.length || !challengeReviews?.length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[💡 maintainability]
Returning an empty array when there are no reviewers or reviews might be correct, but consider logging a warning or info message to help track cases where expected reviewers or reviews are missing.
| return { | ||
| handle: reviewer.memberHandle, | ||
| userId: reviewer.memberId.toString(), | ||
| amount: Math.round( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[correctness]
The calculation of the amount for reviewer payments involves multiple coefficients and a prize value. Ensure that these calculations are thoroughly tested to prevent any logical errors, especially considering rounding operations.
| } | ||
|
|
||
| // need to read for update (LOCK the rows) | ||
| try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[correctness]
Consider using a transaction to ensure atomicity when creating and deleting challenge locks, which can prevent potential race conditions.
… PM-1112_fix-payment-for-place
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
@vas3a there is minor conflict to resolve.
| submissions.map((s) => [s.memberId, s]), | ||
| ); | ||
| return Object.keys(uniqueSubmissions).length; | ||
| const resposne = await this.m2MService.m2mFetch<{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[❗❗ correctness]
Typo in variable name resposne. It should be response to avoid potential confusion and errors.
| await this.winningsRepo.searchWinnings({ | ||
| externalIds: [challengeId], | ||
| externalIds: [challenge.id], | ||
| } as WinningRequestDto) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[maintainability]
The type assertion as WinningRequestDto is used here. Ensure that WinningRequestDto accurately reflects the structure of the object being passed. If the structure changes in the future, this assertion might lead to runtime errors if not updated accordingly.
POST /challenges/:challengeIdnote: this needs to wait for the trolley release, otherwise it will affect dev DB (which is used by dev branch too)