refine answerMeaning support category normalisation
This commit is contained in:
@@ -11,6 +11,10 @@ const TOP_LEVEL_ARRAY_FIELDS = [
|
||||
|
||||
const TOP_LEVEL_NULLABLE_FIELDS = ["selectedQuestion"];
|
||||
|
||||
const ANSWER_SUPPORT_CATEGORY_ALIASES = {
|
||||
conditional_qualification: "conditional_tradeoff",
|
||||
};
|
||||
|
||||
function cloneJsonSafe(value) {
|
||||
if (value == null) return value;
|
||||
return JSON.parse(JSON.stringify(value));
|
||||
@@ -62,6 +66,20 @@ function applyKnownEnumAliases(proposal, normalisationsApplied) {
|
||||
});
|
||||
}
|
||||
|
||||
const supportCategory = proposal.answerMeaning?.supportCategory;
|
||||
const canonicalSupportCategory =
|
||||
ANSWER_SUPPORT_CATEGORY_ALIASES[supportCategory];
|
||||
if (canonicalSupportCategory) {
|
||||
normalisationsApplied.push({
|
||||
path: ["answerMeaning", "supportCategory"],
|
||||
change: `Converted ${supportCategory} to ${canonicalSupportCategory}`,
|
||||
});
|
||||
proposal.answerMeaning = {
|
||||
...proposal.answerMeaning,
|
||||
supportCategory: canonicalSupportCategory,
|
||||
};
|
||||
}
|
||||
|
||||
return proposal;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user