Skip to content

Conversation

@jmgasper
Copy link
Collaborator

Sort reviews on past-challenges by review score in descending order
Show reopen button for registration phase, if submission or TG submission phase is open
https://topcoder.atlassian.net/browse/PS-445

@jmgasper jmgasper requested a review from kkartunov as a code owner November 12, 2025 00:30
@jmgasper jmgasper merged commit 54792d7 into master Nov 12, 2025
10 checks passed
submission,
}))

entries.sort((a: SubmissionScoreEntry, b: SubmissionScoreEntry) => {

Choose a reason for hiding this comment

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

[⚠️ performance]
The sorting logic in sortSubmissionsByReviewScoreDesc could be optimized by using a single comparison function. Consider combining the checks for scoreA and scoreB into one comparison to reduce the number of conditional branches.

const selectedTab = props.selectedTab
const providedReviews = props.reviews
const providedSubmitterReviews = props.submitterReviews
const normalizedSelectedTab = useMemo(

Choose a reason for hiding this comment

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

[💡 performance]
The use of useMemo for normalizedSelectedTab is appropriate, but ensure that the performance benefit justifies the added complexity. If selectedTab changes infrequently, the memoization might not provide significant gains.

() => normalizeTabLabel(selectedTab),
[selectedTab],
)
const shouldSortReviewTabByScore = useMemo(

Choose a reason for hiding this comment

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

[💡 performance]
The useMemo hook for shouldSortReviewTabByScore is used correctly, but consider if the logic is complex enough to warrant memoization. If the computation is trivial, memoization might add unnecessary complexity.

[resolvedSubmitterReviews],
)
const reviewerRowsForReviewTab = useMemo(
() => (shouldSortReviewTabByScore

Choose a reason for hiding this comment

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

[⚠️ performance]
Ensure that sortSubmissionsByReviewScoreDesc is efficient for large datasets. Sorting can be costly, and if filteredReviews or filteredSubmitterReviews are large, this could impact performance.

className?: string
}

const normalizePhaseName = (name?: string): string => (name ? name.trim()

Choose a reason for hiding this comment

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

[💡 maintainability]
Consider adding a return type annotation to normalizePhaseName for better type safety and clarity.

challengePhases.forEach(phase => {
if (!phase?.isOpen || !phase.predecessor) {
const addPhaseIdentifiers = (phase?: BackendPhase): void => {
if (!phase) {

Choose a reason for hiding this comment

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

[⚠️ performance]
The addPhaseIdentifiers function is defined inside useMemo, which could lead to unnecessary re-creations of the function on every render. Consider moving it outside to improve performance.

})

const hasSubmissionVariantOpen = challengePhases.some(phase => (
phase?.isOpen && SUBMISSION_PHASE_NAMES.has(normalizePhaseName(phase.name))

Choose a reason for hiding this comment

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

[💡 performance]
The normalizePhaseName function is called multiple times in the loop. Consider storing the result in a variable to avoid redundant computations.

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.

2 participants