-
Notifications
You must be signed in to change notification settings - Fork 21
Show reopen button for registration phase, if submission or TG submission phase is open (PS-445) #1303
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
…sion phase is open
Show reopen button for registration phase, if submission or TG submission phase is open
| submission, | ||
| })) | ||
|
|
||
| entries.sort((a: SubmissionScoreEntry, b: SubmissionScoreEntry) => { |
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.
[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( |
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.
[💡 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( |
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.
[💡 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 |
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.
[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() |
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]
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) { |
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.
[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)) |
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.
[💡 performance]
The normalizePhaseName function is called multiple times in the loop. Consider storing the result in a variable to avoid redundant computations.
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