fix: alias source-prefixed price history keys

This commit is contained in:
TopherMayor
2026-04-30 11:10:21 -07:00
parent b7a4386e00
commit 09982c2d9c

View File

@@ -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) {