From 6ac3a272ce66a8d5f40fb89e31172814c408a004 Mon Sep 17 00:00:00 2001 From: Tykayn Date: Sun, 27 Apr 2025 23:41:47 +0200 Subject: [PATCH] boolean conversion returns now empty string when enumeration is present --- mappings/engine.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/mappings/engine.ts b/mappings/engine.ts index 2b3533b..302bbf8 100644 --- a/mappings/engine.ts +++ b/mappings/engine.ts @@ -29,7 +29,8 @@ export default class MappingEngine { phones_updated: 0, power_output: 0, phones_updated_list: [], - phones_not_updated: 0 + phones_not_updated: 0, + enumeration_detected: 0 } } @@ -547,8 +548,22 @@ export default class MappingEngine { private convertToYesOrNo(originalValue: any) { - debugLog('convertProperty: ==========> original value', originalValue) + let intermediateValue = '' + originalValue + let isEnumeration = false; let convertedValue = ''; + + // handle lists with ; as separator + if (intermediateValue.includes(';')) { + isEnumeration = true; + intermediateValue = intermediateValue.split(';')[0] + } + // on ne peut pas conclure ce que l'on doit garder avec une liste + if (isEnumeration) { + this.stats.enumeration_detected++ + return '' + } + + debugLog('convertProperty: ==========> original value', originalValue, intermediateValue) if (custom_utils.truthyValues.indexOf(originalValue) !== -1) { convertedValue = 'yes' } else { @@ -559,6 +574,7 @@ export default class MappingEngine { } else { debugLog('convertProperty: ==========> !!! NOT in falsy values', originalValue) } + return convertedValue; }