From b28db015b4c1081ea4287406d0d644e917bc584a Mon Sep 17 00:00:00 2001 From: Tobias Reisinger Date: Thu, 23 May 2024 20:18:11 +0200 Subject: [PATCH] Format code a bit --- Cargo.lock | Bin 70393 -> 72924 bytes src/handlers/mod.rs | 2 +- src/handlers/v1/macros.rs | 28 ++++++++++++++++------------ src/handlers/v1/schedules.rs | 5 ++++- src/handlers/v1/tags.rs | 1 + src/main.rs | 5 ++--- 6 files changed, 24 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9ca1b7e64c13bdd8c548a552938fbf8dd7b41efe..9cd0a0c9a5be1cfa66bdaf8694598488b9910435 100644 GIT binary patch delta 1359 zcmZvc&ud&&6vs(TY7gr?Y4 zS8lrU{sC4*+_+F5h_0lCS{J%>7x%hwA-YjPJu`7?Qrx|F?t}Y1-|y%9e*bWC|I5iw zew%u{!CHd1Y}tP>U!6Su>-?GK%=I+b+3fck%Z(--iWV>1$KF`60;SL@b0akOAc1?& zMN%xuprXi(JC`9C%^+h6=%V9UTb)=&gmU?{`Rb3Q?-u6$;M!*I>Z7-?mMforzqTS# zBvjF{$OXpeb&A}^WWWUB1FE2{<0?aTf+Iw46Q>WgmnO@c%B_!T^YP$@jnE&Y=8H3p z=6FyxURqijzl=^FS#>Dl^v$)l5C&{c41KV|GnKS-ubt^#AKkqfQ*U=8_#Ki`_}Rs&UGjFTES-41F;=qW!=V3vevs>JD`oJA zN-7Y@Jx485N}xdofi8go6}1zB>qMEP93|5+N{(Teh%KG_wb}7S!<9?>tgOC%`QAi% zr8-x=w|skQIt^ml*xTIgR_9mWsUL5MmS~ys@fANI%Jz?!+u&VFmIWof&x+eX0Z3cTAwWB1i}gc=L0}_|L=PFe4Xf8e_{5-*p2e`CEuY1m;{A}I}O^H z((oUG)UY}d&e8#pAUWb|1Ww2U(qq-&PWbgeSoxrxU(MMq*UVq}(xbW&=1Np3k!BZ3H`l0+CJBFpm-QiSX?M(4_{)mr)ai|HpD&92|+;-J6Rql$3R zlBH8UTd~c1?oemy)yxO$rxqSscqB&I0_x7)!CKo#1u_bcj4Ky4p@M-fBe*2_XE{%d zYZ<{v%yb%=bR-*qQdXXT>RhQ^B7}?@wv`GwLMwC!{a%0c*iAPMXzRsvW6QtQAUj&} z=;$EUujZaEr&bs04;62W@Y@-EyGvwV{OsJq5Qg#ma7AdLGI#UM6|Ie<5CqYnluUpD z5Rp?it)l>xW{AlOiJFoH2aIA!L1_yNLn_1UpqD)RQnIyWPQ}9Beqjo{NSI}w$TG>E2$+qx-4=)kT#LSE)llG xoI;7jmAA|(@G>*BmTZThGph27tXEHcyLWnA3UaTy^TYD&fA5RcpFjQe+&_bunic>6 delta 145 zcmcb!ljY}9mJMH6nUr)UZ&)g_S&;3Ut;3gMv2L5 z;}bVuNYLilyf>GZar24%wU$tAlU+^;O_ufG+`M+Bv%u!8Jrj91GoH$4ff?F+E`bTA kviF?8W~qz9ESuk4EfbvVcuI70?Q>fmAVY5Rz0dzN0GX9O*#H0l diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs index 1693e53..5349bfe 100644 --- a/src/handlers/mod.rs +++ b/src/handlers/mod.rs @@ -44,4 +44,4 @@ impl EmgauwaMessage for HttpResponseBuilder { fn emgauwa_message(mut self, message: &str) -> HttpResponse { self.json(json!({ "message": message })) } -} \ No newline at end of file +} diff --git a/src/handlers/v1/macros.rs b/src/handlers/v1/macros.rs index 44b9957..d2d62bf 100644 --- a/src/handlers/v1/macros.rs +++ b/src/handlers/v1/macros.rs @@ -1,14 +1,15 @@ use actix::Addr; -use actix_web::{delete, get, HttpResponse, post, put, web}; -use sqlx::{Pool, Sqlite}; -use sqlx::pool::PoolConnection; - +use actix_web::{delete, get, post, put, web, HttpResponse}; use emgauwa_common::db::{DbController, DbMacro}; use emgauwa_common::errors::{DatabaseError, EmgauwaError}; use emgauwa_common::models::{convert_db_list, FromDbModel, Macro, MacroAction, Relay}; -use emgauwa_common::types::{ControllerWsAction, EmgauwaUid, RequestMacroCreate, RequestMacroExecute, RequestMacroUpdate}; -use crate::app_state; +use emgauwa_common::types::{ + ControllerWsAction, EmgauwaUid, RequestMacroCreate, RequestMacroExecute, RequestMacroUpdate, +}; +use sqlx::pool::PoolConnection; +use sqlx::{Pool, Sqlite}; +use crate::app_state; use crate::app_state::AppState; use crate::handlers::EmgauwaMessage; @@ -133,8 +134,8 @@ pub async fn execute( let affected_controllers = collect_affected_controllers(&mut pool_conn, &actions).await?; for controller in affected_controllers { - - let affected_relays = collect_affected_relays(&mut pool_conn, &mut actions, &controller).await?; + let affected_relays = + collect_affected_relays(&mut pool_conn, &mut actions, &controller).await?; app_state .send(app_state::Action { @@ -159,10 +160,11 @@ async fn collect_affected_controllers( .iter() .any(|controller| controller.id == controller_id) { - continue + continue; } - let controller = DbController::get(pool_conn, controller_id).await? + let controller = DbController::get(pool_conn, controller_id) + .await? .ok_or(DatabaseError::NotFound)?; affected_controllers.push(controller); } @@ -177,7 +179,9 @@ async fn collect_affected_relays( let mut affected_relays: Vec = Vec::new(); for action in actions { - if affected_relays.iter().any(|relay| relay.r.id == action.relay.r.id) + if affected_relays + .iter() + .any(|relay| relay.r.id == action.relay.r.id) || action.relay.r.controller_id != controller.id { continue; @@ -186,4 +190,4 @@ async fn collect_affected_relays( affected_relays.push(action.relay.clone()); } Ok(affected_relays) -} \ No newline at end of file +} diff --git a/src/handlers/v1/schedules.rs b/src/handlers/v1/schedules.rs index 9acc734..61d6497 100644 --- a/src/handlers/v1/schedules.rs +++ b/src/handlers/v1/schedules.rs @@ -3,7 +3,10 @@ use actix_web::{delete, get, post, put, web, HttpResponse}; use emgauwa_common::db::{DbController, DbJunctionRelaySchedule, DbSchedule, DbTag}; use emgauwa_common::errors::{ApiError, DatabaseError, EmgauwaError}; use emgauwa_common::models::{convert_db_list, FromDbModel, Schedule}; -use emgauwa_common::types::{ControllerWsAction, RequestScheduleCreate, RequestScheduleGetTagged, RequestScheduleUpdate, ScheduleUid}; +use emgauwa_common::types::{ + ControllerWsAction, RequestScheduleCreate, RequestScheduleGetTagged, RequestScheduleUpdate, + ScheduleUid, +}; use itertools::Itertools; use sqlx::pool::PoolConnection; use sqlx::{Pool, Sqlite}; diff --git a/src/handlers/v1/tags.rs b/src/handlers/v1/tags.rs index ebf818c..65877c5 100644 --- a/src/handlers/v1/tags.rs +++ b/src/handlers/v1/tags.rs @@ -4,6 +4,7 @@ use emgauwa_common::errors::{DatabaseError, EmgauwaError}; use emgauwa_common::models::{FromDbModel, Tag}; use emgauwa_common::types::RequestTagCreate; use sqlx::{Pool, Sqlite}; + use crate::handlers::EmgauwaMessage; #[get("/tags")] diff --git a/src/main.rs b/src/main.rs index d37a39c..c604d41 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,12 +4,11 @@ use actix::{Actor, Arbiter}; use actix_cors::Cors; use actix_web::middleware::TrailingSlash; use actix_web::{middleware, web, App, HttpServer}; -use serde_json::Value; -use utoipa_swagger_ui::SwaggerUi; - use emgauwa_common::db::DbController; use emgauwa_common::errors::EmgauwaError; use emgauwa_common::utils::{drop_privileges, init_logging}; +use serde_json::Value; +use utoipa_swagger_ui::SwaggerUi; use crate::app_state::AppState;