From e8a0b1d59ea1644e61fdf69e02a16bd8b24f5323 Mon Sep 17 00:00:00 2001 From: SamTV12345 <40429738+samtv12345@users.noreply.github.com> Date: Sun, 1 Oct 2023 10:32:44 +0200 Subject: [PATCH] Fixed error in count query. --- src/db.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/db.rs b/src/db.rs index 978c0c00..18be7ece 100644 --- a/src/db.rs +++ b/src/db.rs @@ -49,13 +49,17 @@ impl TimelineItem { .left_join(ph1.on(ph1.field(ehid).eq(episode_id))) .filter(ph1.field(phistory_date).nullable().eq_any(subquery.clone()) .or(ph1.field(phistory_date).is_null())) - .left_join(favorites.on(f_username.eq(username_to_search.clone()).and(f_podcast_id.eq(pid)))) - .order(date_of_recording.desc()); - let mut query = part_query.clone() + .left_join(favorites.on(f_username.eq(username_to_search.clone()) + .and(f_podcast_id.eq(pid)))); + + let mut query = part_query + .clone() + .order(date_of_recording.desc()) .limit(20) .into_boxed(); let mut total_count = part_query + .clone() .count() .into_boxed(); @@ -72,9 +76,9 @@ impl TimelineItem { total_count = total_count.filter(f_username.eq(username_to_search.clone())); } false => { - if let Some(last_id) = favored_only.last_timestamp { - query = query.filter(date_of_recording.lt(last_id)); - } + if let Some(last_id) = favored_only.last_timestamp { + query = query.filter(date_of_recording.lt(last_id)); + } } } @@ -88,11 +92,11 @@ impl TimelineItem { Option)> (conn) .map_err - (map_db_error)?; + (map_db_error)?; Ok(TimelineItem { total_elements: results, data: result, }) } -} +} \ No newline at end of file