refactor(users): Update usage statistics endpoint and improve macro formatting

This commit is contained in:
vffuunnyy 2025-11-02 13:03:53 +07:00
parent 69eff250b8
commit aba7015311
No known key found for this signature in database
GPG key ID: 5E656A84B06B0AF1
2 changed files with 14 additions and 18 deletions

View file

@ -35,12 +35,12 @@ api_post!(UsersController, bulk_update_all, "/api/users/bulk/all/update", BulkAl
api_post_no_body!(UsersController, bulk_all_reset_traffic, "/api/users/bulk/all/reset-traffic", BulkAllResetTrafficUsersResponseDto);
api_get_with_path_and_query!(
UsersController,
get_usage_by_range,
"/api/users/stats/usage/{}/range",
GetUserUsageByRangeResponseDto,
path_params: [uuid: Uuid],
query_params: [start: Option<String>, end: Option<String>]
UsersController,
get_usage_by_range,
"/api/users/stats/usage/{}/range",
GetUserUsageByRangeResponseDto,
path_params: [uuid: Uuid],
query_params: [start: Option<String>, end: Option<String>]
);
api_post!(UsersController, create_user, "/api/users", CreateUserRequestDto, CreateUserResponseDto, deprecate: "Use create");
@ -69,11 +69,11 @@ api_post!(UsersController, bulk_update_users_internal_squads, "/api/users/bulk/u
api_post!(UsersController, bulk_update_all_users, "/api/users/bulk/all/update", BulkAllUpdateUsersRequestDto, BulkAllUpdateUsersResponseDto, deprecate: "Use bulk_update_all");
api_post_no_body!(UsersController, bulk_all_reset_user_traffic, "/api/users/bulk/all/reset-traffic", BulkAllResetTrafficUsersResponseDto, deprecate: "Use bulk_all_reset_traffic");
api_get_with_path_and_query!(
UsersController,
get_user_usage_by_range,
"/api/users/stats/usage/{}/range",
GetUserUsageByRangeResponseDto,
deprecate: "Use get_usage_by_range",
path_params: [uuid: Uuid],
query_params: [start: Option<String>, end: Option<String>]
UsersController,
get_user_usage_by_range,
"/api/users/stats/usage/{}/range",
GetUserUsageByRangeResponseDto,
deprecate: "Use get_usage_by_range",
path_params: [uuid: Uuid],
query_params: [start: Option<String>, end: Option<String>]
);

View file

@ -405,11 +405,7 @@ macro_rules! api_controller {
async fn handle_text_response(&self, response: reqwest::Response, url: String) -> Result<String, $crate::ApiError> {
let status = response.status();
let response_headers: std::collections::HashMap<String, String> =
response
.headers()
.iter()
.filter_map(|(name, value)| value.to_str().ok().map(|v| (name.to_string(), v.to_string())))
.collect();
response.headers().iter().filter_map(|(name, value)| value.to_str().ok().map(|v| (name.to_string(), v.to_string()))).collect();
let body = response.text().await.unwrap_or_default();
if status.is_success() {