Skip to content

Commit

Permalink
Fixed error in count query.
Browse files Browse the repository at this point in the history
  • Loading branch information
SamTV12345 committed Oct 1, 2023
1 parent c1109cd commit e8a0b1d
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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));
}

}
}
Expand All @@ -88,11 +92,11 @@ impl TimelineItem {
Option<Favorite>)>
(conn)
.map_err
(map_db_error)?;
(map_db_error)?;

Ok(TimelineItem {
total_elements: results,
data: result,
})
}
}
}

0 comments on commit e8a0b1d

Please sign in to comment.