-
Notifications
You must be signed in to change notification settings - Fork 51
Fix an issue where we were making bad requests to load scorecards for… #1705
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,47 @@ const ResourceToPhaseNameMap = { | |
| 'Checkpoint Screener': 'Checkpoint Screening' | ||
| } | ||
|
|
||
| // Keep track filters aligned with the scorecards API regardless of legacy values | ||
| const SCORECARD_TRACK_ALIASES = { | ||
| DEVELOP: 'DEVELOPMENT', | ||
| DEV: 'DEVELOPMENT', | ||
| QA: 'QUALITY_ASSURANCE', | ||
| QUALITY_ASSURANCE: 'QUALITY_ASSURANCE', | ||
| QUALITYASSURANCE: 'QUALITY_ASSURANCE', | ||
| DES: 'DESIGN', | ||
| DESIGN: 'DESIGN', | ||
| DS: 'DATA_SCIENCE', | ||
| DATA_SCIENCE: 'DATA_SCIENCE', | ||
| DATASCIENCE: 'DATA_SCIENCE' | ||
| } | ||
|
|
||
| const normalizeTrackForScorecards = (challenge, metadata) => { | ||
| const normalize = (value) => { | ||
| if (!value) return null | ||
| const normalized = value.toString().trim().toUpperCase().replace(/\s+/g, '_') | ||
| return SCORECARD_TRACK_ALIASES[normalized] || normalized | ||
| } | ||
|
|
||
| if (!challenge) return null | ||
|
|
||
| if (challenge.trackId && metadata && Array.isArray(metadata.challengeTracks)) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| const trackFromMetadata = metadata.challengeTracks.find(t => t.id === challenge.trackId) | ||
| if (trackFromMetadata) { | ||
| return normalize(trackFromMetadata.track || trackFromMetadata.name || trackFromMetadata.abbreviation) | ||
| } | ||
| } | ||
|
|
||
| const { track } = challenge | ||
| if (typeof track === 'string') { | ||
| return normalize(track) | ||
| } | ||
| if (track && typeof track === 'object') { | ||
| return normalize(track.track || track.name || track.abbreviation) | ||
| } | ||
|
|
||
| return null | ||
| } | ||
|
|
||
| class ChallengeReviewerField extends Component { | ||
| constructor (props) { | ||
| super(props) | ||
|
|
@@ -327,19 +368,16 @@ class ChallengeReviewerField extends Component { | |
| } | ||
|
|
||
| loadScorecards () { | ||
| const { challenge, loadScorecards } = this.props | ||
| const { challenge, loadScorecards, metadata } = this.props | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [❗❗ |
||
|
|
||
| const filters = { | ||
| status: 'ACTIVE' | ||
| } | ||
|
|
||
| // Add challenge track if available | ||
| if (challenge.track) { | ||
| if (typeof challenge.track === 'string') { | ||
| filters.challengeTrack = challenge.track.toUpperCase().replace(' ', '_') | ||
| } else if (challenge.track.track) { | ||
| filters.challengeTrack = challenge.track.track | ||
| } | ||
| const normalizedTrack = normalizeTrackForScorecards(challenge, metadata) | ||
| if (normalizedTrack) { | ||
| filters.challengeTrack = normalizedTrack | ||
| } | ||
|
|
||
| // Add challenge type if available | ||
|
|
@@ -1013,7 +1051,8 @@ ChallengeReviewerField.propTypes = { | |
| scorecards: PropTypes.array, | ||
| defaultReviewers: PropTypes.array, | ||
| workflows: PropTypes.array, | ||
| resourceRoles: PropTypes.array | ||
| resourceRoles: PropTypes.array, | ||
| challengeTracks: PropTypes.array | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| }), | ||
| isLoading: PropTypes.bool, | ||
| readOnly: PropTypes.bool, | ||
|
|
||
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 use of
replace(/\s+/g, '_')could lead to unexpected behavior if the input contains multiple spaces. Consider usingreplace(/\s+/g, '_')to ensure consistent normalization.