Skip to content

Commit

Permalink
Don't use LIKE query when username is empty for user search
Browse files Browse the repository at this point in the history
  • Loading branch information
KitaitiMakoto committed Mar 21, 2023
1 parent d6bb2bf commit 213628e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/routes/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,15 @@ pub fn admin_search_users(
rockets: PlumeRocket,
) -> Result<Ructe, ErrorPage> {
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)
Expand Down

0 comments on commit 213628e

Please sign in to comment.