Return len
This commit is contained in:
@@ -23,7 +23,7 @@ fn default_limit() -> usize {
|
||||
100
|
||||
}
|
||||
|
||||
#[derive(Serialize, ToSchema)]
|
||||
#[derive(Debug, Serialize, Deserialize, ToSchema)]
|
||||
pub struct ItemsResponse {
|
||||
pub items: Vec<ItemRef>,
|
||||
pub total: usize,
|
||||
@@ -31,7 +31,7 @@ pub struct ItemsResponse {
|
||||
pub limit: usize,
|
||||
}
|
||||
|
||||
#[derive(Serialize, ToSchema)]
|
||||
#[derive(Debug, Serialize, Deserialize, ToSchema)]
|
||||
pub struct ItemRef {
|
||||
pub source: String,
|
||||
pub key: String,
|
||||
|
||||
@@ -22,6 +22,7 @@ pub struct LookupRequest {
|
||||
#[derive(Debug, Serialize, Deserialize, ToSchema)]
|
||||
pub struct LookupResponse {
|
||||
pub results: Vec<LookupResult>,
|
||||
pub total: u64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, ToSchema)]
|
||||
@@ -66,6 +67,8 @@ pub async fn lookup(
|
||||
}
|
||||
};
|
||||
|
||||
let total: u64 = state.sources.iter().map(|x| x.1.len() as u64).sum();
|
||||
|
||||
debug!(
|
||||
message = "Served /lookup",
|
||||
query = body.query,
|
||||
@@ -73,5 +76,5 @@ pub async fn lookup(
|
||||
time_ms = start.elapsed().as_millis()
|
||||
);
|
||||
|
||||
return (StatusCode::OK, Json(LookupResponse { results })).into_response();
|
||||
return (StatusCode::OK, Json(LookupResponse { results, total })).into_response();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user