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

Commit e0179e9

Browse files
bool to string
1 parent b69a15c commit e0179e9

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

src/services/ProcessorService.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,9 +690,10 @@ async function processUpdate (message) {
690690
// logger.debug('Parsed Payload', saveDraftContestDTO)
691691
try {
692692
// extract metadata from challenge and insert into IFX
693+
let metaValue
693694
for (const metadataKey of _.keys(constants.supportedMetadata)) {
694695
try {
695-
const metaValue = constants.supportedMetadata[metadataKey].method(message.payload, constants.supportedMetadata[metadataKey].defaultValue)
696+
metaValue = constants.supportedMetadata[metadataKey].method(message.payload, constants.supportedMetadata[metadataKey].defaultValue)
696697
if (metaValue !== null) {
697698
logger.info(`Setting ${constants.supportedMetadata[metadataKey].description} to ${metaValue}`)
698699
await metadataService.createOrUpdateMetadata(legacyId, metadataKey, metaValue, _.get(message, 'payload.updatedBy') || _.get(message, 'payload.createdBy'))

src/utils/metadataExtractor.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ const _ = require('lodash')
1010
*/
1111
const getMeta = (metadata = [], key) => _.find(metadata, meta => meta.name === key)
1212

13-
/**
14-
* Convert string to bool
15-
* @param {String} v the value
16-
*/
17-
const toBool = v => _.toString(v).toLowerCase() === 'true'
18-
1913
/**
2014
* Extract billing project
2115
* @param {Object} challenge the challenge object
@@ -74,7 +68,7 @@ function extractDrPoints (challenge, defaultValue) {
7468
function extractApprovalRequired (challenge, defaultValue) {
7569
const entry = getMeta(challenge.metadata, 'approvalRequired')
7670
if (!entry) return defaultValue
77-
return toBool(entry.value)
71+
return _.toString(entry.value)
7872
}
7973

8074
/**
@@ -85,7 +79,7 @@ function extractApprovalRequired (challenge, defaultValue) {
8579
function extractPostMortemRequired (challenge, defaultValue) {
8680
const entry = getMeta(challenge.metadata, 'postMortemRequired')
8781
if (!entry) return defaultValue
88-
return toBool(entry.value)
82+
return _.toString(entry.value)
8983
}
9084

9185
/**
@@ -96,7 +90,7 @@ function extractPostMortemRequired (challenge, defaultValue) {
9690
function extractTrackLateDeliverablesRequired (challenge, defaultValue) {
9791
const entry = getMeta(challenge.metadata, 'trackLateDeliverables')
9892
if (!entry) return defaultValue
99-
return toBool(entry.value)
93+
return _.toString(entry.value)
10094
}
10195

10296
/**
@@ -107,7 +101,7 @@ function extractTrackLateDeliverablesRequired (challenge, defaultValue) {
107101
function extractAllowStockArtRequired (challenge, defaultValue) {
108102
const entry = getMeta(challenge.metadata, 'allowStockArt')
109103
if (!entry) return defaultValue
110-
return toBool(entry.value)
104+
return _.toString(entry.value)
111105
}
112106

113107
/**
@@ -118,7 +112,7 @@ function extractAllowStockArtRequired (challenge, defaultValue) {
118112
function extractSubmissionViewable (challenge, defaultValue) {
119113
const entry = getMeta(challenge.metadata, 'submissionViewable')
120114
if (!entry) return defaultValue
121-
return toBool(entry.value)
115+
return _.toString(entry.value)
122116
}
123117

124118
/**
@@ -129,7 +123,7 @@ function extractSubmissionViewable (challenge, defaultValue) {
129123
function extractReviewFeedback (challenge, defaultValue) {
130124
const entry = getMeta(challenge.metadata, 'reviewFeedback')
131125
if (!entry) return defaultValue
132-
return toBool(entry.value)
126+
return _.toString(entry.value)
133127
}
134128

135129
/**

0 commit comments

Comments
 (0)