Skip to content

PROD HOTFIX - Handle strings or booleans for show_data_dashboard flag #1586

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

Merged
merged 11 commits into from
Dec 14, 2023
3 changes: 2 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ install_dependency: &install_dependency
sudo apt update
sudo apt install python3-pip
sudo pip3 install awscli --upgrade
sudo pip3 install docker==6.1.3
sudo pip3 install docker-compose

install_test_dependency: &install_test_dependency
Expand Down Expand Up @@ -152,7 +153,7 @@ workflows:
context : org-global
filters: &filters-dev
branches:
only: ['develop', 'multiround', 'release_0.20.9']
only: ['develop', 'multiround', 'release_0.20.9', 'metadata-fix']

# Production builds are exectuted only on tagged commits to the
# master branch.
Expand Down
4 changes: 3 additions & 1 deletion src/components/ChallengeEditor/ChallengeView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ const ChallengeView = ({
const showCheckpointPrizes = _.get(challenge, 'timelineTemplateId') === MULTI_ROUND_CHALLENGE_TEMPLATE_ID
const isDataScience = challenge.trackId === DS_TRACK_ID
const useDashboardData = _.find(challenge.metadata, { name: 'show_data_dashboard' })
const useDashboard = useDashboardData ? useDashboardData.value : true
const useDashboard = useDashboardData
? (_.isString(useDashboardData.value) && useDashboardData.value === 'true') ||
(_.isBoolean(useDashboardData.value) && useDashboardData.value) : false

return (
<div className={styles.wrapper}>
Expand Down
11 changes: 9 additions & 2 deletions src/components/ChallengeEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1069,8 +1069,11 @@ class ChallengeEditor extends Component {
}
let useDashboard = _.find(challengeMetadata, { name: 'show_data_dashboard' })
if (useDashboard === undefined) {
useDashboard = { name: 'show_data_dashboard', value: true }
useDashboard = { name: 'show_data_dashboard', value: 'false' }
} else if (_.isBoolean(useDashboard.value)) {
useDashboard = { name: 'show_data_dashboard', value: _.toString(useDashboard.value) }
}

newChallenge.metadata.push(useDashboard)
}
try {
Expand Down Expand Up @@ -1646,7 +1649,11 @@ class ChallengeEditor extends Component {
const showCheckpointPrizes = challenge.timelineTemplateId === MULTI_ROUND_CHALLENGE_TEMPLATE_ID
const showDashBoard = (challenge.trackId === DS_TRACK_ID && isChallengeType) || (isDevChallenge && isMM)
const useDashboardData = _.find(challenge.metadata, { name: 'show_data_dashboard' })
const useDashboard = useDashboardData ? useDashboardData.value : true

const useDashboard = useDashboardData
? (_.isString(useDashboardData.value) && useDashboardData.value === 'true') ||
(_.isBoolean(useDashboardData.value) && useDashboardData.value) : false

const workTypes = getDomainTypes(challenge.trackId)
const filteredTypes = metadata.challengeTypes.filter(type => workTypes.includes(type.abbreviation))

Expand Down
10 changes: 10 additions & 0 deletions src/util/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,5 +198,15 @@ export const updateChallengePhaseBeforeSendRequest = (challengeDetail) => {
}))
return challengeDetailTmp
}
if (challengeDetail.metadata && challengeDetail.metadata.length > 0) {
challengeDetail.metadata = challengeDetail.metadata.map(m => {
// check if value is boolean and convert to string
if (typeof m.value === 'boolean') {
m.value = m.value.toString()
}

return m
})
}
return challengeDetail
}