Skip to content

Update end-of-challenge placement handling#28

Merged
jmgasper merged 2 commits into
masterfrom
develop
Feb 18, 2026
Merged

Update end-of-challenge placement handling#28
jmgasper merged 2 commits into
masterfrom
develop

Conversation

@jmgasper

Copy link
Copy Markdown
Contributor

@jmgasper jmgasper merged commit 0c1df28 into master Feb 18, 2026
5 of 6 checks passed

const [, winners] = challengeApiService.completeChallenge.mock.calls[0];
expect(winners).toHaveLength(2);
expect(winners).toHaveLength(3);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[⚠️ correctness]
The change from expect(winners).toHaveLength(2); to expect(winners).toHaveLength(3); suggests that the logic now allows for more winners than placement prizes. Ensure that this change aligns with the business requirements and that there is no unintended impact on prize distribution.

expect(winners.map((winner) => winner.userId)).toEqual([101, 102]);
expect(winners.map((winner) => winner.placement)).toEqual([1, 2]);
expect(winners).toHaveLength(3);
expect(winners.map((winner) => winner.userId)).toEqual([101, 101, 102]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[⚠️ correctness]
The expectation expect(winners.map((winner) => winner.userId)).toEqual([101, 101, 102]); implies that a single user can have multiple placements. Verify that this behavior is intended and that it does not violate any business rules regarding unique placements per user.

'Topcoder Post Mortem',
);
} catch (_) {
} catch {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[💡 maintainability]
The change from catch (_) to catch removes the unused variable _, which is a good practice. However, ensure that the logging inside the reviewService is comprehensive enough to capture all necessary error details, as this catch block no longer handles any specific error.

if (timeA === timeB) {
return 0;
const timeDiff =
this.getSubmissionTimestamp(a.submittedDate) -

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[⚠️ correctness]
The method getSubmissionTimestamp is used to calculate the time difference between submissions. Ensure that the logic for handling null dates (returning 0) aligns with the intended sorting behavior, as this could affect the order of submissions with null dates.

}
const winners = [...placementWinners, ...passedReviewWinners];

await this.challengeApiService.completeChallenge(challengeId, winners);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[⚠️ correctness]
The completeChallenge method is called with both placementWinners and passedReviewWinners combined into winners. Ensure that the downstream logic in completeChallenge correctly handles both types of winners, as this could affect the challenge completion process.

REVIEW_PHASE_NAMES.has(data.phaseTypeName);

if (operation === 'open' && isReviewPhase) {
const canOpenNow =

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[❗❗ correctness]
The ensureAssignmentsOrSchedule method is called with an async callback that immediately calls advancePhase. This could potentially lead to a recursive call if advancePhase ends up calling this block again. Ensure that there is a termination condition or a mechanism to prevent infinite recursion.

},
);

if (!canOpenNow) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[💡 maintainability]
The return statement here exits the function if canOpenNow is false, but it might be more informative to log why the phase cannot be opened. Consider adding a log statement before returning.

{
userId: 456,
handle: 'runner-up',
placement: 1,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[❗❗ correctness]
The placement value for the 'runner-up' is set to 1, which is the same as the 'winner'. This might be a mistake if placements are supposed to be unique. Verify if this is intentional.

where: {
challengeId,
type: {
in: [PrizeSetTypeEnum.PLACEMENT, PrizeSetTypeEnum.PASSED_REVIEW],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[⚠️ correctness]
Consider verifying that PrizeSetTypeEnum.PASSED_REVIEW is a valid type for the context of this operation. If this type is not expected to be used here, it could lead to unintended deletions.

placement: winner.placement,
type: PrizeSetTypeEnum.PLACEMENT,
type:
winner.type === PrizeSetTypeEnum.PASSED_REVIEW

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[⚠️ correctness]
The conditional logic here assumes that winner.type can only be PrizeSetTypeEnum.PASSED_REVIEW or defaults to PrizeSetTypeEnum.PLACEMENT. Ensure that winner.type is validated before this point to prevent unexpected behavior if other types are introduced.

handle: string;
placement: number;
type?: string;
type?: PrizeSetTypeEnum;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[❗❗ correctness]
Changing the type of type from string to PrizeSetTypeEnum is a breaking change if this interface is used in contexts expecting a string. Ensure that all usages of IChallengeWinner are updated accordingly to handle PrizeSetTypeEnum values. If backward compatibility is needed, consider providing a migration path or versioning the API.

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.

1 participant