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:
kappa
2026-01-25 19:41:42 +09:00
parent 67d86be5d5
commit f6c35067f9
2 changed files with 24 additions and 1 deletions

View File

@@ -12,7 +12,8 @@ import type {
BandwidthEstimate, BandwidthEstimate,
RecommendationResult, RecommendationResult,
BenchmarkReference, BenchmarkReference,
AIRecommendationResponse AIRecommendationResponse,
AvailableRegion
} from '../types'; } from '../types';
import { i18n, LIMITS } from '../config'; import { i18n, LIMITS } from '../config';
import { import {
@@ -1054,6 +1055,20 @@ The option with the LOWEST TOTAL MONTHLY COST (including bandwidth) should have
// Calculate bandwidth info for this server // Calculate bandwidth info for this server
const bandwidthInfo = calculateBandwidthInfo(server, bandwidthEstimate); 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({ results.push({
server: server, server: server,
score: aiRec.score, 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, performance_per_dollar: matchingVPS.performance_per_dollar,
} }
: undefined, : undefined,
available_regions: availableRegions.length > 0 ? availableRegions : undefined,
}); });
if (results.length >= 3) break; if (results.length >= 3) break;

View File

@@ -59,6 +59,12 @@ export interface BandwidthInfo {
warning?: string; // 트래픽 관련 경고 warning?: string; // 트래픽 관련 경고
} }
export interface AvailableRegion {
region_name: string;
region_code: string;
monthly_price: number;
}
export interface RecommendationResult { export interface RecommendationResult {
server: Server; server: Server;
score: number; score: number;
@@ -82,6 +88,7 @@ export interface RecommendationResult {
monthly_price_usd: number; monthly_price_usd: number;
performance_per_dollar: number; performance_per_dollar: number;
}; };
available_regions?: AvailableRegion[];
} }
export interface BenchmarkReference { export interface BenchmarkReference {