fix row and page counts

This commit is contained in:
Bryan Stitt 2022-12-14 18:45:54 -08:00
parent 44ca5a50f1
commit fbafcca528
2 changed files with 11 additions and 8 deletions

@ -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.
#[debug_handler]
pub async fn user_revert_logs_get(
Extension(app): Extension<Arc<Web3ProxyApp>>,
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.
#[debug_handler]
pub async fn user_stats_aggregated_get(
Extension(app): Extension<Arc<Web3ProxyApp>>,
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.
#[debug_handler]
pub async fn user_stats_detailed_get(
Extension(app): Extension<Arc<Web3ProxyApp>>,
bearer: Option<TypedHeader<Authorization<Bearer>>>,

@ -264,10 +264,6 @@ pub async fn query_user_stats<'a>(
let q = rpc_accounting::Entity::find()
.select_only()
.column_as(
rpc_accounting::Column::FrontendRequests.count(),
"total_rows",
)
.column_as(
rpc_accounting::Column::FrontendRequests.sum(),
"total_frontend_requests",
@ -400,7 +396,17 @@ pub async fn query_user_stats<'a>(
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
.into_json()
.paginate(&db_conn, page_size)