fix: alias source-prefixed price history keys
This commit is contained in:
15
server.js
15
server.js
@@ -63,6 +63,14 @@ function normalizeKey(value) {
|
|||||||
.replace(/^-+|-+$/g, '');
|
.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) {
|
function toTextList(value) {
|
||||||
const items = Array.isArray(value) ? value : value == null ? [] : [value];
|
const items = Array.isArray(value) ? value : value == null ? [] : [value];
|
||||||
|
|
||||||
@@ -109,8 +117,7 @@ function readJsonLines(filePath) {
|
|||||||
function getOptionHistoryKeys(option) {
|
function getOptionHistoryKeys(option) {
|
||||||
const nameKey = normalizeKey(option.name);
|
const nameKey = normalizeKey(option.name);
|
||||||
const categoryNameKey = option.categoryId && nameKey ? `${option.categoryId}-${nameKey}` : '';
|
const categoryNameKey = option.categoryId && nameKey ? `${option.categoryId}-${nameKey}` : '';
|
||||||
|
const rawKeys = [
|
||||||
return [...new Set([
|
|
||||||
option.seedKey,
|
option.seedKey,
|
||||||
option.id,
|
option.id,
|
||||||
option.priceKey,
|
option.priceKey,
|
||||||
@@ -118,7 +125,9 @@ function getOptionHistoryKeys(option) {
|
|||||||
option.slug,
|
option.slug,
|
||||||
categoryNameKey,
|
categoryNameKey,
|
||||||
nameKey,
|
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) {
|
function extractNumericPrice(point) {
|
||||||
|
|||||||
Reference in New Issue
Block a user