From 4eeb519ae5398b5b5f5c7d9938e3887cac2c9faf Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sat, 24 Aug 2024 11:24:17 +0200 Subject: feat(videos): Allow limiting the number of videos to show --- src/videos/mod.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/videos') diff --git a/src/videos/mod.rs b/src/videos/mod.rs index 5bf34e3..b51e469 100644 --- a/src/videos/mod.rs +++ b/src/videos/mod.rs @@ -20,16 +20,19 @@ use crate::{ storage::video_database::{getters::get_videos, VideoStatus}, }; -pub async fn query(app: &App, search_query: Option) -> Result<()> { - let all_videos = get_videos(app, &VideoStatus::ALL, None).await?; +pub async fn query(app: &App, limit: Option, search_query: Option) -> Result<()> { + let all_videos = get_videos(app, VideoStatus::ALL, None).await?; // turn one video to a color display, to pre-warm the hash shrinking cache if let Some(val) = all_videos.get(0) { val.to_color_display(app).await?; } + let limit = limit.unwrap_or(all_videos.len()); + let all_video_strings: Vec = all_videos .into_iter() + .take(limit) .map(|vid| vid.to_color_display_owned(app)) .collect::>() .try_collect() -- cgit 1.4.1