feat: add area diagnostics

This commit is contained in:
2026-06-24 16:06:18 +08:00
parent b002c44218
commit e6f26152d1
6 changed files with 314 additions and 12 deletions

View File

@@ -332,11 +332,33 @@ export type AreaMonthlyMetric = {
raw_artifact_id: number | null;
};
export type DiagnosticMetric = {
key: string;
label: string;
unit: string;
current_value: number;
percentile: number;
historical_min: number;
historical_max: number;
sample_size: number;
anomaly: boolean;
anomaly_direction: string | null;
severity: string;
};
export type AreaDiagnostics = {
area_id: string;
month: string;
metrics: DiagnosticMetric[];
anomaly_count: number;
};
export type AreaDetail = {
profile: AreaProfile;
current_score: AreaScore | null;
score_lineage: AreaScoreLineage | null;
monthly_metrics: AreaMonthlyMetric[];
diagnostics: AreaDiagnostics | null;
neighborhood_scores: NeighborhoodScore[];
};
@@ -400,6 +422,15 @@ export async function fetchAreaDetail(areaId: string, month: string): Promise<Ar
);
}
export async function fetchAreaDiagnostics(
areaId: string,
month: string,
): Promise<AreaDiagnostics> {
return fetchJson(
`/api/v1/areas/${encodeURIComponent(areaId)}/diagnostics?month=${encodeURIComponent(month)}`,
);
}
export async function fetchNeighborhoodScores(month: string): Promise<NeighborhoodScore[]> {
return fetchJson(`/api/v1/neighborhoods/scores?month=${encodeURIComponent(month)}`);
}