From a587459a1817c0fc57b46df3f9c69567e1e775b7 Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Tue, 12 Dec 2023 18:20:56 +0000 Subject: refactor: separate model and controller --- src/routes/home.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src/routes/home.rs') diff --git a/src/routes/home.rs b/src/routes/home.rs index 11d3a72..a43eabc 100644 --- a/src/routes/home.rs +++ b/src/routes/home.rs @@ -8,12 +8,7 @@ use crate::{Pinussy, Result}; async fn get(session: Session, state: web::Data) -> Result { let username: Option; if let Some(user_id) = session.get::("user_id")? { - username = Some( - sqlx::query!("select username from users where id = $1", user_id) - .fetch_one(&state.db) - .await? - .username, - ) + username = Some(state.db.users().read(user_id).await?.username) } else { username = None } -- cgit