diff options
author | metamuffin <metamuffin@disroot.org> | 2025-01-29 18:03:06 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-01-29 18:03:06 +0100 |
commit | db511d3fe50f05329615f718515fab1b80d9e06a (patch) | |
tree | 7969fea01be100cbe4385ad13a14940a987ac513 /server/src/routes/ui/sort.rs | |
parent | 82e8a55a1496ae9132e13e7286fe1c0d57d586d3 (diff) | |
download | jellything-db511d3fe50f05329615f718515fab1b80d9e06a.tar jellything-db511d3fe50f05329615f718515fab1b80d9e06a.tar.bz2 jellything-db511d3fe50f05329615f718515fab1b80d9e06a.tar.zst |
no direct redb access
Diffstat (limited to 'server/src/routes/ui/sort.rs')
-rw-r--r-- | server/src/routes/ui/sort.rs | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/server/src/routes/ui/sort.rs b/server/src/routes/ui/sort.rs index bb71184..705b616 100644 --- a/server/src/routes/ui/sort.rs +++ b/server/src/routes/ui/sort.rs @@ -134,10 +134,10 @@ pub enum SortOrder { pub fn filter_and_sort_nodes( f: &NodeFilterSort, default_sort: (SortProperty, SortOrder), - nodes: &mut Vec<(String, Node, NodeUserData)>, + nodes: &mut Vec<(Node, NodeUserData)>, ) { let sort_prop = f.sort_by.unwrap_or(default_sort.0); - nodes.retain(|(_id, node, udata)| { + nodes.retain(|(node, udata)| { let mut o = true; if let Some(prop) = &f.filter_kind { for p in FilterProperty::ALL { @@ -175,34 +175,32 @@ pub fn filter_and_sort_nodes( }); match sort_prop { SortProperty::Duration => { - nodes.sort_by_key(|(_, n, _)| (n.media.as_ref().unwrap().duration * 1000.) as i64) + nodes.sort_by_key(|(n, _)| (n.media.as_ref().unwrap().duration * 1000.) as i64) } SortProperty::ReleaseDate => { - nodes.sort_by_key(|(_, n, _)| n.release_date.expect("asserted above")) + nodes.sort_by_key(|(n, _)| n.release_date.expect("asserted above")) } - SortProperty::Title => nodes.sort_by(|(_, a, _), (_, b, _)| a.title.cmp(&b.title)), - SortProperty::RatingRottenTomatoes => nodes.sort_by_cached_key(|(_, n, _)| { + SortProperty::Title => nodes.sort_by(|(a, _), (b, _)| a.title.cmp(&b.title)), + SortProperty::RatingRottenTomatoes => nodes.sort_by_cached_key(|(n, _)| { SortAnyway(*n.ratings.get(&Rating::RottenTomatoes).unwrap_or(&0.)) }), - SortProperty::RatingMetacritic => nodes.sort_by_cached_key(|(_, n, _)| { + SortProperty::RatingMetacritic => nodes.sort_by_cached_key(|(n, _)| { SortAnyway(*n.ratings.get(&Rating::Metacritic).unwrap_or(&0.)) }), - SortProperty::RatingImdb => nodes.sort_by_cached_key(|(_, n, _)| { - SortAnyway(*n.ratings.get(&Rating::Imdb).unwrap_or(&0.)) - }), - SortProperty::RatingTmdb => nodes.sort_by_cached_key(|(_, n, _)| { - SortAnyway(*n.ratings.get(&Rating::Tmdb).unwrap_or(&0.)) - }), - SortProperty::RatingYoutubeViews => nodes.sort_by_cached_key(|(_, n, _)| { + SortProperty::RatingImdb => nodes + .sort_by_cached_key(|(n, _)| SortAnyway(*n.ratings.get(&Rating::Imdb).unwrap_or(&0.))), + SortProperty::RatingTmdb => nodes + .sort_by_cached_key(|(n, _)| SortAnyway(*n.ratings.get(&Rating::Tmdb).unwrap_or(&0.))), + SortProperty::RatingYoutubeViews => nodes.sort_by_cached_key(|(n, _)| { SortAnyway(*n.ratings.get(&Rating::YoutubeViews).unwrap_or(&0.)) }), - SortProperty::RatingYoutubeLikes => nodes.sort_by_cached_key(|(_, n, _)| { + SortProperty::RatingYoutubeLikes => nodes.sort_by_cached_key(|(n, _)| { SortAnyway(*n.ratings.get(&Rating::YoutubeLikes).unwrap_or(&0.)) }), - SortProperty::RatingYoutubeFollowers => nodes.sort_by_cached_key(|(_, n, _)| { + SortProperty::RatingYoutubeFollowers => nodes.sort_by_cached_key(|(n, _)| { SortAnyway(*n.ratings.get(&Rating::YoutubeFollowers).unwrap_or(&0.)) }), - SortProperty::RatingUser => nodes.sort_by_cached_key(|(_, _, u)| u.rating), + SortProperty::RatingUser => nodes.sort_by_cached_key(|(_, u)| u.rating), } match f.sort_order.unwrap_or(default_sort.1) { |