Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Fix zero copilot payments #52

Merged
merged 2 commits into from
Apr 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/services/ProcessorService.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ async function associateChallengeTerms (v5Terms, legacyChallengeId, createdBy, u
*/
async function setCopilotPayment (challengeId, legacyChallengeId, prizeSets = [], createdBy, updatedBy, m2mToken) {
try {
const copilotPayment = _.get(_.find(prizeSets, p => p.type === config.COPILOT_PAYMENT_TYPE), 'prizes[0].value', null)
const copilotPayment = _.get(_.find(prizeSets, p => p.type === config.COPILOT_PAYMENT_TYPE), 'prizes[0].value', 0)
if (copilotPayment) {
logger.debug('Fetching challenge copilot...')
const res = await helper.getRequest(`${config.V5_RESOURCES_API_URL}?challengeId=${challengeId}&roleId=${config.COPILOT_ROLE_ID}`, m2mToken)
Expand All @@ -264,9 +264,7 @@ async function setCopilotPayment (challengeId, legacyChallengeId, prizeSets = []
return
}
logger.debug(`Setting Copilot Payment: ${copilotPayment} for legacyId ${legacyChallengeId} for copilot ${copilotResource.memberId}`)
if (copilotPayment !== null && copilotPayment >= 0) {
await copilotPaymentService.setManualCopilotPayment(legacyChallengeId, createdBy, updatedBy)
}
await copilotPaymentService.setManualCopilotPayment(legacyChallengeId, createdBy, updatedBy)
await copilotPaymentService.setCopilotPayment(legacyChallengeId, copilotPayment, createdBy, updatedBy)
}
} catch (e) {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/metadataExtractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ function extractEstimateEffortHours (challenge, defaultValue) {
* @param {Any} defaultValue the default value
*/
function extractEstimateEffortOffshore (challenge, defaultValue) {
const entry = getMeta(challenge.metadata, 'effortHoursOffshore')
const entry = getMeta(challenge.metadata, 'offshoreEfforts')
if (!entry) return _.toString(defaultValue)
return _.toNumber(entry.value)
}
Expand All @@ -176,7 +176,7 @@ function extractEstimateEffortOffshore (challenge, defaultValue) {
* @param {Any} defaultValue the default value
*/
function extractEstimateEffortOnsite (challenge, defaultValue) {
const entry = getMeta(challenge.metadata, 'effortHoursOnshore')
const entry = getMeta(challenge.metadata, 'onsiteEfforts')
if (!entry) return _.toString(defaultValue)
return _.toNumber(entry.value)
}
Expand Down