mirror of
https://wget.la/https://github.com/leookun/cursor-byok
synced 2026-10-05 20:44:07 +08:00
36 lines
773 B
Rust
36 lines
773 B
Rust
//! HTTP handler for the desktop overview aggregates.
|
|
|
|
use axum::{
|
|
extract::{Query, State},
|
|
Json,
|
|
};
|
|
use serde::Deserialize;
|
|
|
|
use crate::{model::Overview, Result};
|
|
|
|
use super::ControlService;
|
|
|
|
#[derive(Debug, Default, Deserialize)]
|
|
pub struct OverviewRange {
|
|
start_ms: Option<i64>,
|
|
end_ms: Option<i64>,
|
|
model_hashes: Option<String>,
|
|
provider_ids: Option<String>,
|
|
}
|
|
|
|
pub async fn get(
|
|
State(service): State<ControlService>,
|
|
Query(range): Query<OverviewRange>,
|
|
) -> Result<Json<Overview>> {
|
|
Ok(Json(
|
|
service
|
|
.overview(
|
|
range.start_ms,
|
|
range.end_ms,
|
|
range.model_hashes.as_deref(),
|
|
range.provider_ids.as_deref(),
|
|
)
|
|
.await?,
|
|
))
|
|
}
|