From 6529652916a3b40c06faebcc99e5aeb32ba3e8c1 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Wed, 6 Nov 2024 17:48:32 +0100 Subject: [PATCH] controllers/summary: Remove unnecessary `.is_empty()` conditions If we pass in an empty array then so be it, but there is no need for the boxed and mutated queries here :) --- src/controllers/summary.rs | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/controllers/summary.rs b/src/controllers/summary.rs index 78990f73b22..073efd87ebc 100644 --- a/src/controllers/summary.rs +++ b/src/controllers/summary.rs @@ -96,34 +96,24 @@ pub async fn summary(state: AppState) -> AppResult> { .load(&mut conn) .await?; - let mut most_downloaded_query = crates::table + let most_downloaded = crates::table .inner_join(crate_downloads::table) .left_join(recent_crate_downloads::table) .left_join(default_versions::table) .left_join(versions::table.on(default_versions::version_id.eq(versions::id))) - .into_boxed(); - if !config.excluded_crate_names.is_empty() { - most_downloaded_query = - most_downloaded_query.filter(crates::name.ne_all(&config.excluded_crate_names)); - } - let most_downloaded = most_downloaded_query + .filter(crates::name.ne_all(&config.excluded_crate_names)) .then_order_by(crate_downloads::downloads.desc()) .select(selection) .limit(10) .load(&mut conn) .await?; - let mut most_recently_downloaded_query = crates::table + let most_recently_downloaded = crates::table .inner_join(crate_downloads::table) .inner_join(recent_crate_downloads::table) .left_join(default_versions::table) .left_join(versions::table.on(default_versions::version_id.eq(versions::id))) - .into_boxed(); - if !config.excluded_crate_names.is_empty() { - most_recently_downloaded_query = most_recently_downloaded_query - .filter(crates::name.ne_all(&config.excluded_crate_names)); - } - let most_recently_downloaded = most_recently_downloaded_query + .filter(crates::name.ne_all(&config.excluded_crate_names)) .then_order_by(recent_crate_downloads::downloads.desc()) .select(selection) .limit(10)