From 213628e400bd275bf60746d7ca9cc070c006afc6 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Tue, 21 Mar 2023 19:07:09 +0900 Subject: [PATCH] Don't use LIKE query when username is empty for user search --- src/routes/instance.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/routes/instance.rs b/src/routes/instance.rs index 90c0b764..9de9fee0 100644 --- a/src/routes/instance.rs +++ b/src/routes/instance.rs @@ -185,9 +185,15 @@ pub fn admin_search_users( rockets: PlumeRocket, ) -> Result { let page = page.unwrap_or_default(); + let users = if user.is_empty() { + User::get_local_page(&conn, page.limits())? + } else { + User::search_local_by_name(&conn, &user, page.limits())? + }; + Ok(render!(instance::users( &(&conn, &rockets).to_context(), - User::search_local_by_name(&conn, &user, page.limits())?, + users, Some(user.as_str()), page.0, Page::total(User::count_local(&conn)? as i32)