Fix city selector fallback coverage

This commit is contained in:
2569718930@qq.com
2026-05-27 21:02:08 +08:00
parent fb7e27d9ed
commit 4d22191a2d
3 changed files with 95 additions and 3 deletions
@@ -61,3 +61,25 @@ export function cityListItemsToScanRows(cities: CityListItem[]): ScanOpportunity
};
});
}
export function mergeScanRowsWithCityFallbackRows(
scanRows: ScanOpportunityRow[],
fallbackRows: ScanOpportunityRow[],
): ScanOpportunityRow[] {
const merged = [...(scanRows || [])];
const seen = new Set<string>();
for (const row of merged) {
const key = normalizeCityKey(row.city || row.city_display_name || row.display_name || "");
if (key) seen.add(key);
}
for (const row of fallbackRows || []) {
const key = normalizeCityKey(row.city || row.city_display_name || row.display_name || "");
if (!key || seen.has(key)) continue;
seen.add(key);
merged.push(row);
}
return merged;
}