refactor(health): add dashboard overview and related drill-down

- Replace health monitor tabs with a dashboard layout
- Add related health drill-down for endpoint, model, and provider cards
- Render provider health as cards and hide empty monitors
This commit is contained in:
AAEE86
2026-06-02 00:10:59 +08:00
parent 0e6fc96eb1
commit d5d3f09846
26 changed files with 1943 additions and 204 deletions
@@ -552,6 +552,16 @@ fn usage_matches_breakdown_summary_query(
return false;
}
}
if let Some(model) = query.model.as_deref() {
if item.model != model {
return false;
}
}
if let Some(api_format) = query.api_format.as_deref() {
if item.api_format.as_deref() != Some(api_format) {
return false;
}
}
if item
.status_code
.is_some_and(|status_code| query.exclude_status_codes.contains(&status_code))
@@ -4841,6 +4841,18 @@ WITH filtered_usage AS (
.push("\"usage\".provider_name = ")
.push_bind(provider_name.to_string());
}
if let Some(model) = query.model.as_deref() {
builder.push(if has_where { " AND " } else { " WHERE " });
builder
.push("\"usage\".model = ")
.push_bind(model.to_string());
}
if let Some(api_format) = query.api_format.as_deref() {
builder.push(if has_where { " AND " } else { " WHERE " });
builder
.push("\"usage\".api_format = ")
.push_bind(api_format.to_string());
}
push_postgres_usage_excluded_status_codes(
&mut builder,
&mut has_where,
@@ -4944,6 +4956,12 @@ ORDER BY request_count DESC, group_key ASC
if query.provider_name.is_some() {
return self.summarize_usage_breakdown_raw(query).await;
}
if query.model.is_some() {
return self.summarize_usage_breakdown_raw(query).await;
}
if query.api_format.is_some() {
return self.summarize_usage_breakdown_raw(query).await;
}
let Some(user_id) = query.user_id.as_deref() else {
return self.summarize_usage_breakdown_raw(query).await;
};
@@ -4966,6 +4984,8 @@ ORDER BY request_count DESC, group_key ASC
created_until_unix_secs: dashboard_utc_to_unix_secs(raw_end),
user_id: Some(user_id.to_string()),
provider_name: None,
model: None,
api_format: None,
exclude_status_codes: query.exclude_status_codes.clone(),
group_by: query.group_by,
})
@@ -4990,6 +5010,8 @@ ORDER BY request_count DESC, group_key ASC
created_until_unix_secs: dashboard_utc_to_unix_secs(raw_end),
user_id: Some(user_id.to_string()),
provider_name: None,
model: None,
api_format: None,
exclude_status_codes: query.exclude_status_codes.clone(),
group_by: query.group_by,
})
@@ -2490,6 +2490,18 @@ FROM "usage"
"provider_name",
query.provider_name.as_deref(),
);
push_sqlite_usage_optional_text_filter(
&mut builder,
&mut has_where,
"model",
query.model.as_deref(),
);
push_sqlite_usage_optional_text_filter(
&mut builder,
&mut has_where,
"api_format",
query.api_format.as_deref(),
);
push_sqlite_usage_excluded_status_codes(
&mut builder,
&mut has_where,