feat: add available_regions to recommendations
- Add AvailableRegion interface in types.ts - Show all regions where the same server spec is available - Helps users see regional options (e.g., Tokyo and Osaka for japan) - Sorted by price, excludes current region Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -12,7 +12,8 @@ import type {
|
||||
BandwidthEstimate,
|
||||
RecommendationResult,
|
||||
BenchmarkReference,
|
||||
AIRecommendationResponse
|
||||
AIRecommendationResponse,
|
||||
AvailableRegion
|
||||
} from '../types';
|
||||
import { i18n, LIMITS } from '../config';
|
||||
import {
|
||||
@@ -1054,6 +1055,20 @@ The option with the LOWEST TOTAL MONTHLY COST (including bandwidth) should have
|
||||
// Calculate bandwidth info for this server
|
||||
const bandwidthInfo = calculateBandwidthInfo(server, bandwidthEstimate);
|
||||
|
||||
// Find all available regions for the same server spec
|
||||
const availableRegions: AvailableRegion[] = candidates
|
||||
.filter(c =>
|
||||
c.provider_name === server.provider_name &&
|
||||
c.instance_id === server.instance_id &&
|
||||
c.region_code !== server.region_code // Exclude current region
|
||||
)
|
||||
.map(c => ({
|
||||
region_name: c.region_name,
|
||||
region_code: c.region_code,
|
||||
monthly_price: c.monthly_price
|
||||
}))
|
||||
.sort((a, b) => a.monthly_price - b.monthly_price);
|
||||
|
||||
results.push({
|
||||
server: server,
|
||||
score: aiRec.score,
|
||||
@@ -1070,6 +1085,7 @@ The option with the LOWEST TOTAL MONTHLY COST (including bandwidth) should have
|
||||
performance_per_dollar: matchingVPS.performance_per_dollar,
|
||||
}
|
||||
: undefined,
|
||||
available_regions: availableRegions.length > 0 ? availableRegions : undefined,
|
||||
});
|
||||
|
||||
if (results.length >= 3) break;
|
||||
|
||||
Reference in New Issue
Block a user