fix row and page counts
This commit is contained in:
parent
44ca5a50f1
commit
fbafcca528
@ -724,7 +724,6 @@ pub async fn rpc_keys_management(
|
|||||||
|
|
||||||
/// `GET /user/revert_logs` -- Use a bearer token to get the user's revert logs.
|
/// `GET /user/revert_logs` -- Use a bearer token to get the user's revert logs.
|
||||||
#[debug_handler]
|
#[debug_handler]
|
||||||
|
|
||||||
pub async fn user_revert_logs_get(
|
pub async fn user_revert_logs_get(
|
||||||
Extension(app): Extension<Arc<Web3ProxyApp>>,
|
Extension(app): Extension<Arc<Web3ProxyApp>>,
|
||||||
TypedHeader(Authorization(bearer)): TypedHeader<Authorization<Bearer>>,
|
TypedHeader(Authorization(bearer)): TypedHeader<Authorization<Bearer>>,
|
||||||
@ -780,7 +779,6 @@ pub async fn user_revert_logs_get(
|
|||||||
|
|
||||||
/// `GET /user/stats/aggregate` -- Public endpoint for aggregate stats such as bandwidth used and methods requested.
|
/// `GET /user/stats/aggregate` -- Public endpoint for aggregate stats such as bandwidth used and methods requested.
|
||||||
#[debug_handler]
|
#[debug_handler]
|
||||||
|
|
||||||
pub async fn user_stats_aggregated_get(
|
pub async fn user_stats_aggregated_get(
|
||||||
Extension(app): Extension<Arc<Web3ProxyApp>>,
|
Extension(app): Extension<Arc<Web3ProxyApp>>,
|
||||||
bearer: Option<TypedHeader<Authorization<Bearer>>>,
|
bearer: Option<TypedHeader<Authorization<Bearer>>>,
|
||||||
@ -801,7 +799,6 @@ pub async fn user_stats_aggregated_get(
|
|||||||
///
|
///
|
||||||
/// TODO: this will change as we add better support for secondary users.
|
/// TODO: this will change as we add better support for secondary users.
|
||||||
#[debug_handler]
|
#[debug_handler]
|
||||||
|
|
||||||
pub async fn user_stats_detailed_get(
|
pub async fn user_stats_detailed_get(
|
||||||
Extension(app): Extension<Arc<Web3ProxyApp>>,
|
Extension(app): Extension<Arc<Web3ProxyApp>>,
|
||||||
bearer: Option<TypedHeader<Authorization<Bearer>>>,
|
bearer: Option<TypedHeader<Authorization<Bearer>>>,
|
||||||
|
@ -264,10 +264,6 @@ pub async fn query_user_stats<'a>(
|
|||||||
|
|
||||||
let q = rpc_accounting::Entity::find()
|
let q = rpc_accounting::Entity::find()
|
||||||
.select_only()
|
.select_only()
|
||||||
.column_as(
|
|
||||||
rpc_accounting::Column::FrontendRequests.count(),
|
|
||||||
"total_rows",
|
|
||||||
)
|
|
||||||
.column_as(
|
.column_as(
|
||||||
rpc_accounting::Column::FrontendRequests.sum(),
|
rpc_accounting::Column::FrontendRequests.sum(),
|
||||||
"total_frontend_requests",
|
"total_frontend_requests",
|
||||||
@ -400,7 +396,17 @@ pub async fn query_user_stats<'a>(
|
|||||||
serde_json::to_value(page_size).expect("can't fail"),
|
serde_json::to_value(page_size).expect("can't fail"),
|
||||||
);
|
);
|
||||||
|
|
||||||
// query the database
|
// query the database for number of items and pages
|
||||||
|
let pages_result = q
|
||||||
|
.clone()
|
||||||
|
.paginate(&db_conn, page_size)
|
||||||
|
.num_items_and_pages()
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
response.insert("num_items", pages_result.number_of_items.into());
|
||||||
|
response.insert("num_pages", pages_result.number_of_pages.into());
|
||||||
|
|
||||||
|
// query the database (todo: combine with the pages_result query?)
|
||||||
let query_response = q
|
let query_response = q
|
||||||
.into_json()
|
.into_json()
|
||||||
.paginate(&db_conn, page_size)
|
.paginate(&db_conn, page_size)
|
||||||
|
Loading…
Reference in New Issue
Block a user