Skip to content

Conversation

@vas3a
Copy link
Collaborator

@vas3a vas3a commented Oct 20, 2025

  • added a challenge_lock table for preventing multiple parallel calls to POST /challenges/:challengeId
  • split the logic for placement, copilot, and reviewer payments into methods, for better tracking
  • updated the logic for reviewer payments to be based on reviews count instead of submissions count

note: this needs to wait for the trolley release, otherwise it will affect dev DB (which is used by dev branch too)

@vas3a vas3a requested review from jmgasper and kkartunov October 20, 2025 07:08
submissions.map((s) => [s.memberId, s]),
);
return Object.keys(uniqueSubmissions).length;
const resposne = await this.m2MService.m2mFetch<{

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!');

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) {

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(

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 {

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.

Copy link
Contributor

@kkartunov kkartunov left a 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.

@vas3a vas3a merged commit de47623 into v6 Oct 22, 2025
1 check passed
@vas3a vas3a deleted the PM-1112_fix-payment-for-place branch October 22, 2025 06:56
submissions.map((s) => [s.memberId, s]),
);
return Object.keys(uniqueSubmissions).length;
const resposne = await this.m2MService.m2mFetch<{

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)

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants