refactor: 🔨 linting

This commit is contained in:
Lucas Colombo 2024-03-28 15:33:12 -03:00
parent 4ee49e571a
commit 5d80f46e6e
Signed by: lucas
GPG Key ID: EF34786CFEFFAE35
5 changed files with 42 additions and 41 deletions

58
.vscode/settings.json vendored
View File

@ -1,38 +1,38 @@
{ {
"files.exclude": { "files.exclude": {
// // 🧩 modules // 🧩 modules
// "migration": true, "migration": true,
// // "entities": true, // "entities": true,
// // //
// ".env": true, ".env": true,
// "Taskfile.yaml": true, "Taskfile.yaml": true,
// ".cocorc": true, ".cocorc": true,
// ".task": true, ".task": true,
// ".cargo": true, ".cargo": true,
// ".github": true, ".github": true,
// "rustfmt.toml": true, "rustfmt.toml": true,
// // "**/**/Cargo.toml": true, // "**/**/Cargo.toml": true,
// // 📦 // 📦
// "Cargo.lock": true, "Cargo.lock": true,
// "target": true, "target": true,
// // 📝 readmes // 📝 readmes
// "**/**/README.md": true, "**/**/README.md": true,
// "LICENSE": true, "LICENSE": true,
// // 🗑 // 🗑
// "check_size.py": true, "check_size.py": true,
// "*.code-workspace": true, "*.code-workspace": true,
// // ".gitignore": true, // ".gitignore": true,
// ".vscode": true, ".vscode": true,
// ".git": true, ".git": true,
// // 🗄 database // 🗄 database
// "rustler.db": true, "rustler.db": true,
// "rustler.db-shm": true, "rustler.db-shm": true,
// "rustler.db-wal": true, "rustler.db-wal": true,
// "rustler.db.bkp": true, "rustler.db.bkp": true,
} }
} }

View File

@ -30,6 +30,11 @@ tasks:
- python check_size.py - python check_size.py
fmt: fmt:
desc: 🚀 format rustler desc: 🎨 format rustler
cmds: cmds:
- cargo +nightly fmt --all - cargo +nightly fmt --all
lint:
desc: 🧶 lint rustler
cmds:
- cargo clippy --fix --workspace --allow-dirty

View File

@ -2,7 +2,7 @@ use {
dotenvy::dotenv, dotenvy::dotenv,
entities::sea_orm::{ConnectionTrait, Database, DbBackend, Statement}, entities::sea_orm::{ConnectionTrait, Database, DbBackend, Statement},
eyre::Result, eyre::Result,
std::sync::{Arc, Mutex}, std::sync::Arc,
}; };
// TODO: here we will trigger the start of both the grpc server and the websocket gateway // TODO: here we will trigger the start of both the grpc server and the websocket gateway

View File

@ -2,10 +2,7 @@ use {
super::{Entity as MarketEntity, Model as MarketModel}, super::{Entity as MarketEntity, Model as MarketModel},
eyre::Result, eyre::Result,
sea_orm::{DatabaseConnection, EntityTrait, IntoActiveModel}, sea_orm::{DatabaseConnection, EntityTrait, IntoActiveModel},
std::{ std::{sync::Arc, time::Instant},
sync::{Arc, Mutex},
time::Instant,
},
}; };
pub struct Service { pub struct Service {

View File

@ -1,8 +1,7 @@
use { use {
core::time,
entities::{market, sea_orm::DatabaseConnection}, entities::{market, sea_orm::DatabaseConnection},
eyre::Result, eyre::Result,
std::{env, sync::Arc, thread, time::Instant}, std::{sync::Arc, time::Instant},
tonic::{transport::Server, Request, Response, Status}, tonic::{transport::Server, Request, Response, Status},
}; };
@ -57,10 +56,10 @@ pub struct GrpcServer {
impl MarketApi for GrpcServer { impl MarketApi for GrpcServer {
async fn get_all(&self, _: Request<Empty>) -> Result<Response<Markets>, Status> { async fn get_all(&self, _: Request<Empty>) -> Result<Response<Markets>, Status> {
let start = Instant::now(); let start = Instant::now();
if let Some(mkts) = self.svc.get_all().await.ok() { if let Ok(mkts) = self.svc.get_all().await {
println!("get_all took {:?}", start.elapsed()); println!("get_all took {:?}", start.elapsed());
Ok(Response::new(Markets { Ok(Response::new(Markets {
markets: mkts.into_iter().map(|m| Market::from_model(m)).collect(), markets: mkts.into_iter().map(Market::from_model).collect(),
})) }))
} else { } else {
println!("get_all took {:?}", start.elapsed()); println!("get_all took {:?}", start.elapsed());
@ -72,7 +71,7 @@ impl MarketApi for GrpcServer {
let start = Instant::now(); let start = Instant::now();
let mkt = market.into_inner().into_model(); let mkt = market.into_inner().into_model();
if let Some(m) = self.svc.create(mkt).await.ok() { if let Ok(m) = self.svc.create(mkt).await {
println!("create took {:?}", start.elapsed()); println!("create took {:?}", start.elapsed());
Ok(Response::new(Market::from_model(m))) Ok(Response::new(Market::from_model(m)))
} else { } else {