diff options
author | metamuffin <metamuffin@disroot.org> | 2023-12-16 01:08:15 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-12-16 01:08:15 +0100 |
commit | af99c406af8ee47bee38708cf23e86af826e41ba (patch) | |
tree | 23498a36f813454c2edea46906f812d929ba792e /server/src/routes/ui/sort.rs | |
parent | 21b58037c69798e922c5512ea5380943781558ff (diff) | |
download | jellything-af99c406af8ee47bee38708cf23e86af826e41ba.tar jellything-af99c406af8ee47bee38708cf23e86af826e41ba.tar.bz2 jellything-af99c406af8ee47bee38708cf23e86af826e41ba.tar.zst |
watch progress and some draft ui
Diffstat (limited to 'server/src/routes/ui/sort.rs')
-rw-r--r-- | server/src/routes/ui/sort.rs | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/server/src/routes/ui/sort.rs b/server/src/routes/ui/sort.rs index 10ba356..d8a44b2 100644 --- a/server/src/routes/ui/sort.rs +++ b/server/src/routes/ui/sort.rs @@ -1,4 +1,4 @@ -use jellycommon::{helpers::SortAnyway, NodeKind, NodePublic, Rating}; +use jellycommon::{helpers::SortAnyway, user::NodeUserData, NodeKind, NodePublic, Rating}; use rocket::{ http::uri::fmt::{Query, UriDisplay}, FromForm, FromFormField, UriDisplayQuery, @@ -79,8 +79,11 @@ enum SortOrder { #[field(value = "descending")] Descending, } -pub fn filter_and_sort_nodes(f: &NodeFilterSort, nodes: &mut Vec<(String, NodePublic)>) { - nodes.retain(|(_id, node)| { +pub fn filter_and_sort_nodes( + f: &NodeFilterSort, + nodes: &mut Vec<(String, NodePublic, NodeUserData)>, +) { + nodes.retain(|(_id, node, _udata)| { let mut o = true; if let Some(prop) = &f.filter_kind { for (p, _) in FilterProperty::ALL { @@ -109,25 +112,25 @@ pub fn filter_and_sort_nodes(f: &NodeFilterSort, nodes: &mut Vec<(String, NodePu if let Some(sort_prop) = &f.sort_by { match sort_prop { 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)| { + SortProperty::RatingImdb => nodes.sort_by_cached_key(|(_, n, _)| { SortAnyway(*n.ratings.get(&Rating::Imdb).unwrap_or(&0.)) }), - SortProperty::RatingYoutubeViews => nodes.sort_by_cached_key(|(_, n)| { + 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.)) }), } |