From 78df4177a6ff88917e96863766d2881af13b4559 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Mon, 12 Dec 2022 11:00:15 -0800 Subject: [PATCH] consistent case --- entities/src/sea_orm_active_enums.rs | 5 +++-- web3_proxy/src/app_stats.rs | 2 +- web3_proxy/src/frontend/mod.rs | 6 +++++- web3_proxy/src/frontend/users.rs | 10 +++++++--- web3_proxy/src/user_queries.rs | 2 +- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/entities/src/sea_orm_active_enums.rs b/entities/src/sea_orm_active_enums.rs index 185f4901..475db7d6 100644 --- a/entities/src/sea_orm_active_enums.rs +++ b/entities/src/sea_orm_active_enums.rs @@ -5,11 +5,12 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Serialize, Deserialize)] #[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "log_level")] +#[strum(serialize_all = "lowercase")] pub enum LogLevel { #[sea_orm(string_value = "none")] None, - #[sea_orm(string_value = "aggregate")] - Aggregate, + #[sea_orm(string_value = "aggregated")] + Aggregated, #[sea_orm(string_value = "detailed")] Detailed, } diff --git a/web3_proxy/src/app_stats.rs b/web3_proxy/src/app_stats.rs index 09c9ae63..5adddbd6 100644 --- a/web3_proxy/src/app_stats.rs +++ b/web3_proxy/src/app_stats.rs @@ -60,7 +60,7 @@ impl ProxyResponseStat { // keep the method since the rpc key is not attached Some(self.method.clone()) } - LogLevel::Aggregate => { + LogLevel::Aggregated => { // Lose the method None } diff --git a/web3_proxy/src/frontend/mod.rs b/web3_proxy/src/frontend/mod.rs index 4faaaf58..f77b30c0 100644 --- a/web3_proxy/src/frontend/mod.rs +++ b/web3_proxy/src/frontend/mod.rs @@ -71,7 +71,11 @@ pub async fn serve(port: u16, proxy_app: Arc) -> anyhow::Result<() .route("/user/revert_logs", get(users::user_revert_logs_get)) .route( "/user/stats/aggregate", - get(users::user_stats_aggregate_get), + get(users::user_stats_aggregated_get), + ) + .route( + "/user/stats/aggregated", + get(users::user_stats_aggregated_get), ) .route("/user/stats/detailed", get(users::user_stats_detailed_get)) .route("/user/logout", post(users::user_logout_post)) diff --git a/web3_proxy/src/frontend/users.rs b/web3_proxy/src/frontend/users.rs index 2ee769fb..0d1fdec5 100644 --- a/web3_proxy/src/frontend/users.rs +++ b/web3_proxy/src/frontend/users.rs @@ -547,10 +547,14 @@ pub async fn rpc_keys_management( // TODO: limit to 10 keys? let secret_key = RpcSecretKey::new(); + let log_level = payload + .log_level + .context("log level must be 'none', 'detailed', or 'aggregated'")?; + rpc_key::ActiveModel { user_id: sea_orm::Set(user.id), secret_key: sea_orm::Set(secret_key.into()), - log_level: sea_orm::Set(payload.log_level.unwrap_or(LogLevel::None)), + log_level: sea_orm::Set(log_level), ..Default::default() } }; @@ -743,12 +747,12 @@ 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_aggregate_get( +pub async fn user_stats_aggregated_get( Extension(app): Extension>, bearer: Option>>, Query(params): Query>, ) -> FrontendResult { - let response = query_user_stats(&app, bearer, ¶ms, StatResponse::Aggregate).await?; + let response = query_user_stats(&app, bearer, ¶ms, StatResponse::Aggregated).await?; Ok(Json(response).into_response()) } diff --git a/web3_proxy/src/user_queries.rs b/web3_proxy/src/user_queries.rs index d4e3ae81..d6edf197 100644 --- a/web3_proxy/src/user_queries.rs +++ b/web3_proxy/src/user_queries.rs @@ -194,7 +194,7 @@ pub fn filter_query_window_seconds( } pub enum StatResponse { - Aggregate, + Aggregated, Detailed, }