From 0726375859125eb159977604d285597e35bfb9e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mina=20Gali=C4=87?= Date: Sun, 24 May 2020 21:03:59 +0200 Subject: [PATCH] add another async (and correctly convert followers_count) --- src/routes/posts.rs | 2 +- src/routes/user.rs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/routes/posts.rs b/src/routes/posts.rs index e3bc3426..9fc0ad51 100644 --- a/src/routes/posts.rs +++ b/src/routes/posts.rs @@ -401,7 +401,7 @@ pub fn valid_slug(title: &str) -> Result<(), ValidationError> { } #[post("/~//new", data = "
")] -pub fn create( +pub async fn create( blog_name: String, form: LenientForm, cl: ContentLen, diff --git a/src/routes/user.rs b/src/routes/user.rs index eca17a68..1606abb1 100644 --- a/src/routes/user.rs +++ b/src/routes/user.rs @@ -277,7 +277,10 @@ pub async fn followers( let conn = &*rockets.conn; let page = page.unwrap_or_default(); let user: User = User::find_by_fqn(&rockets, &name).await?; - let followers_count = user.count_followers(&conn); + let followers_count = match user.count_followers(&conn) { + Ok(num) => num, + Err(_) => 0, + }; Ok(render!(users::followers( &rockets.to_context(),