-
Notifications
You must be signed in to change notification settings - Fork 51
Points support updates #1714
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
Points support updates #1714
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,14 +3,13 @@ import PropTypes from 'prop-types' | |
| import { connect } from 'react-redux' | ||
| import cn from 'classnames' | ||
| import { PrimaryButton, OutlineButton } from '../../Buttons' | ||
| import { REVIEW_OPPORTUNITY_TYPE_LABELS, REVIEW_OPPORTUNITY_TYPES, VALIDATION_VALUE_TYPE, MARATHON_TYPE_ID, DES_TRACK_ID, CHALLENGE_PRIZE_TYPE } from '../../../config/constants' | ||
| import { REVIEW_OPPORTUNITY_TYPE_LABELS, REVIEW_OPPORTUNITY_TYPES, VALIDATION_VALUE_TYPE, MARATHON_TYPE_ID, DES_TRACK_ID } from '../../../config/constants' | ||
| import { loadScorecards, loadDefaultReviewers, loadWorkflows, replaceResourceInRole, createResource, deleteResource } from '../../../actions/challenges' | ||
| import styles from './ChallengeReviewer-Field.module.scss' | ||
| import { validateValue } from '../../../util/input-check' | ||
| import AssignedMemberField from '../AssignedMember-Field' | ||
| import { getResourceRoleByName } from '../../../util/tc' | ||
| import { isEqual } from 'lodash' | ||
| import { getPrizeType } from '../../../util/prize' | ||
|
|
||
| const ResourceToPhaseNameMap = { | ||
| Reviewer: 'Review', | ||
|
|
@@ -960,8 +959,7 @@ class ChallengeReviewerField extends Component { | |
| } | ||
|
|
||
| getFirstPlacePrizeValue (challenge) { | ||
| const prizeSets = challenge.prizeSets || [] | ||
| const placementPrizeSet = prizeSets.find(set => set.type === 'PLACEMENT') | ||
| const placementPrizeSet = challenge.prizeSets.find(set => set.type === 'PLACEMENT') | ||
|
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. [ |
||
| if (placementPrizeSet && placementPrizeSet.prizes && placementPrizeSet.prizes[0] && placementPrizeSet.prizes[0].value) { | ||
| return placementPrizeSet.prizes[0].value | ||
| } | ||
|
|
@@ -973,23 +971,20 @@ class ChallengeReviewerField extends Component { | |
| const { error } = this.state | ||
| const { scorecards = [], defaultReviewers = [], workflows = [] } = metadata | ||
| const reviewers = challenge.reviewers || [] | ||
| const prizeType = getPrizeType(challenge.prizeSets) | ||
| const firstPlacePrize = prizeType === CHALLENGE_PRIZE_TYPE.POINT ? 0 : this.getFirstPlacePrizeValue(challenge) | ||
| const firstPlacePrize = this.getFirstPlacePrizeValue(challenge) | ||
| const estimatedSubmissionsCount = 2 // Estimate assumes two submissions | ||
| const reviewersCost = prizeType === CHALLENGE_PRIZE_TYPE.POINT | ||
| ? '0.00' | ||
| : reviewers | ||
| .filter((r) => !this.isAIReviewer(r)) | ||
| .reduce((sum, r) => { | ||
| const fixedAmount = parseFloat(r.fixedAmount || 0) | ||
| const baseCoefficient = parseFloat(r.baseCoefficient || 0) | ||
| const incrementalCoefficient = parseFloat(r.incrementalCoefficient || 0) | ||
| const reviewerCost = fixedAmount + (baseCoefficient + incrementalCoefficient * estimatedSubmissionsCount) * firstPlacePrize | ||
|
|
||
| const count = parseInt(r.memberReviewerCount) || 1 | ||
| return sum + reviewerCost * count | ||
| }, 0) | ||
| .toFixed(2) | ||
| const reviewersCost = reviewers | ||
| .filter((r) => !this.isAIReviewer(r)) | ||
| .reduce((sum, r) => { | ||
| const fixedAmount = parseFloat(r.fixedAmount || 0) | ||
| const baseCoefficient = parseFloat(r.baseCoefficient || 0) | ||
| const incrementalCoefficient = parseFloat(r.incrementalCoefficient || 0) | ||
| const reviewerCost = fixedAmount + (baseCoefficient + incrementalCoefficient * estimatedSubmissionsCount) * firstPlacePrize | ||
|
|
||
| const count = parseInt(r.memberReviewerCount) || 1 | ||
| return sum + reviewerCost * count | ||
| }, 0) | ||
| .toFixed(2) | ||
|
|
||
| if (isLoading) { | ||
| return ( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,7 @@ const CheckpointPrizesField = ({ challenge, onUpdateOthers, readOnly }) => { | |
| const checkpointPrize = prizeSets.find(p => p.type === type) || { type: PRIZE_SETS_TYPE.CHECKPOINT_PRIZES, prizes: [], 'description': 'Checkpoint Prizes' } | ||
| const number = _.get(checkpointPrize, 'prizes.length') || DEFAULT_CHECKPOINT_PRIZE_COUNT | ||
| const amount = _.get(checkpointPrize, 'prizes.length') ? checkpointPrize.prizes[0].value : DEFAULT_CHECKPOINT_PRIZE | ||
| const prizeType = getPrizeType(prizeSets) | ||
| const prizeType = _.get(checkpointPrize, 'prizes[0].type') || getPrizeType(prizeSets) | ||
|
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. [❗❗ |
||
|
|
||
| // update the check point prize with default values if it's not already defined | ||
| if (_.get(checkpointPrize, 'prizes.length') === 0) { | ||
|
|
@@ -54,7 +54,9 @@ const CheckpointPrizesField = ({ challenge, onUpdateOthers, readOnly }) => { | |
| <div> | ||
| <div className={styles.checkpointPrizeInputContainer}> | ||
| <div className={styles.checkpointPrizeAmountContainer}> | ||
| <FontAwesomeIcon className={styles.dollarIcon} icon={faDollarSign} /> | ||
| {prizeType === CHALLENGE_PRIZE_TYPE.POINT | ||
| ? <span className={styles.pointsLabel}>Pts</span> | ||
| : <FontAwesomeIcon className={styles.dollarIcon} icon={faDollarSign} />} | ||
| </div> | ||
| <input id='checkpointPrize' name='checkpointPrize' type='text' placeholder='' value={amount} maxLength='7' required onChange={(e) => onChange(number, e.target.value)} /> | ||
|
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. [ |
||
| </div> | ||
|
|
||
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 import of
CHALLENGE_PRIZE_TYPEhas been removed, but it is still used in the code. Ensure that this constant is either re-imported or that its usage is removed or replaced.