diff --git a/server.js b/server.js index be47572..3960895 100644 --- a/server.js +++ b/server.js @@ -63,6 +63,14 @@ function normalizeKey(value) { .replace(/^-+|-+$/g, ''); } +const HISTORY_KEY_ALIASES = { + 'costco-breathless': 'hotel-breathless', + 'costco-grand-fiesta': 'hotel-grand-fiesta', + 'costco-secrets': 'hotel-secrets', + 'costco-corazon': 'hotel-corazon', + 'costco-pacifica': 'hotel-pacifica', +}; + function toTextList(value) { const items = Array.isArray(value) ? value : value == null ? [] : [value]; @@ -109,8 +117,7 @@ function readJsonLines(filePath) { function getOptionHistoryKeys(option) { const nameKey = normalizeKey(option.name); const categoryNameKey = option.categoryId && nameKey ? `${option.categoryId}-${nameKey}` : ''; - - return [...new Set([ + const rawKeys = [ option.seedKey, option.id, option.priceKey, @@ -118,7 +125,9 @@ function getOptionHistoryKeys(option) { option.slug, categoryNameKey, nameKey, - ].filter(Boolean).map(normalizeKey))]; + ].filter(Boolean).map(normalizeKey); + + return [...new Set(rawKeys.flatMap((key) => [key, HISTORY_KEY_ALIASES[key] || null].filter(Boolean)))]; } function extractNumericPrice(point) {