feat: add similar neighborhood analysis

This commit is contained in:
2026-06-24 16:20:36 +08:00
parent e6f26152d1
commit b559df50d8
6 changed files with 474 additions and 11 deletions

View File

@@ -366,9 +366,55 @@ export type NeighborhoodDetail = {
profile: Neighborhood;
current_score: NeighborhoodScore | null;
monthly_metrics: NeighborhoodMonthlyMetric[];
similar_neighborhoods: SimilarNeighborhood[];
watchlist_items: WatchlistItem[];
};
export type SimilarNeighborhoodCandidate = {
neighborhood_id: string;
area_id: string;
name: string;
area_name: string;
district: string;
built_year: number | null;
property_type: string;
metro_distance_m: number | null;
school_quality: string | null;
month: string;
investment_score: number;
recommendation: string;
transaction_price_psm: number;
annual_rent_yield_pct: number;
liquidity_score: number;
location_score: number;
building_age_score: number;
};
export type SimilarNeighborhood = {
neighborhood_id: string;
area_id: string;
name: string;
area_name: string;
district: string;
built_year: number | null;
property_type: string;
metro_distance_m: number | null;
school_quality: string | null;
investment_score: number;
recommendation: string;
transaction_price_psm: number;
annual_rent_yield_pct: number;
similarity_score: number;
relative_price_pct: number;
reasons: string[];
};
export type SimilarNeighborhoodResponse = {
target: SimilarNeighborhoodCandidate;
month: string;
items: SimilarNeighborhood[];
};
export type ComparisonMetricValue = {
id: string;
value: number | null;
@@ -444,6 +490,16 @@ export async function fetchNeighborhoodDetail(
);
}
export async function fetchSimilarNeighborhoods(
neighborhoodId: string,
month: string,
limit = 8,
): Promise<SimilarNeighborhoodResponse> {
return fetchJson(
`/api/v1/neighborhoods/${encodeURIComponent(neighborhoodId)}/similar?month=${encodeURIComponent(month)}&limit=${limit}`,
);
}
export async function fetchAreaComparison(
areaIds: string[],
month: string,