diff options
| author | metamuffin <metamuffin@disroot.org> | 2025-11-18 12:08:34 +0100 |
|---|---|---|
| committer | metamuffin <metamuffin@disroot.org> | 2025-11-18 12:08:34 +0100 |
| commit | bac47e456085ea153ae6ae1b1e28e41868693c9c (patch) | |
| tree | 062c157d66faa3935c1175433732d30c07d1cd5b /logic | |
| parent | f3af9263b0472bcef3207906ce0e4d1d4aa3595b (diff) | |
| download | jellything-bac47e456085ea153ae6ae1b1e28e41868693c9c.tar jellything-bac47e456085ea153ae6ae1b1e28e41868693c9c.tar.bz2 jellything-bac47e456085ea153ae6ae1b1e28e41868693c9c.tar.zst | |
start reworking model
Diffstat (limited to 'logic')
| -rw-r--r-- | logic/src/assets.rs | 2 | ||||
| -rw-r--r-- | logic/src/filter_sort.rs | 20 | ||||
| -rw-r--r-- | logic/src/home.rs | 6 |
3 files changed, 14 insertions, 14 deletions
diff --git a/logic/src/assets.rs b/logic/src/assets.rs index c6d6a11..02d0c2e 100644 --- a/logic/src/assets.rs +++ b/logic/src/assets.rs @@ -58,7 +58,7 @@ pub fn get_node_person_asset( .get_node(id)? .ok_or(anyhow!("node does not exist"))?; let app = node - .people + .credits .get(&group) .ok_or(anyhow!("group has no members"))? .get(index) diff --git a/logic/src/filter_sort.rs b/logic/src/filter_sort.rs index 3ccbc0d..d3244af 100644 --- a/logic/src/filter_sort.rs +++ b/logic/src/filter_sort.rs @@ -4,7 +4,7 @@ Copyright (C) 2025 metamuffin <metamuffin.org> */ use jellycommon::{ - Node, NodeKind, Rating, + Node, NodeKind, RatingType, api::{FilterProperty, NodeFilterSort, SortOrder, SortProperty}, helpers::SortAnyway, user::NodeUserData, @@ -65,28 +65,28 @@ pub fn filter_and_sort_nodes( .cmp(&b.index.unwrap_or(usize::MAX)) }), SortProperty::RatingRottenTomatoes => nodes.sort_by_cached_key(|(n, _)| { - SortAnyway(*n.ratings.get(&Rating::RottenTomatoes).unwrap_or(&0.)) + SortAnyway(*n.ratings.get(&RatingType::RottenTomatoes).unwrap_or(&0.)) }), SortProperty::RatingMetacritic => nodes.sort_by_cached_key(|(n, _)| { - SortAnyway(*n.ratings.get(&Rating::Metacritic).unwrap_or(&0.)) + SortAnyway(*n.ratings.get(&RatingType::Metacritic).unwrap_or(&0.)) }), SortProperty::RatingImdb => nodes - .sort_by_cached_key(|(n, _)| SortAnyway(*n.ratings.get(&Rating::Imdb).unwrap_or(&0.))), + .sort_by_cached_key(|(n, _)| SortAnyway(*n.ratings.get(&RatingType::Imdb).unwrap_or(&0.))), SortProperty::RatingTmdb => nodes - .sort_by_cached_key(|(n, _)| SortAnyway(*n.ratings.get(&Rating::Tmdb).unwrap_or(&0.))), + .sort_by_cached_key(|(n, _)| SortAnyway(*n.ratings.get(&RatingType::Tmdb).unwrap_or(&0.))), SortProperty::RatingYoutubeViews => nodes.sort_by_cached_key(|(n, _)| { - SortAnyway(*n.ratings.get(&Rating::YoutubeViews).unwrap_or(&0.)) + SortAnyway(*n.ratings.get(&RatingType::YoutubeViews).unwrap_or(&0.)) }), SortProperty::RatingYoutubeLikes => nodes.sort_by_cached_key(|(n, _)| { - SortAnyway(*n.ratings.get(&Rating::YoutubeLikes).unwrap_or(&0.)) + SortAnyway(*n.ratings.get(&RatingType::YoutubeLikes).unwrap_or(&0.)) }), SortProperty::RatingYoutubeFollowers => nodes.sort_by_cached_key(|(n, _)| { - SortAnyway(*n.ratings.get(&Rating::YoutubeFollowers).unwrap_or(&0.)) + SortAnyway(*n.ratings.get(&RatingType::YoutubeFollowers).unwrap_or(&0.)) }), SortProperty::RatingLikesDivViews => nodes.sort_by_cached_key(|(n, _)| { SortAnyway( - *n.ratings.get(&Rating::YoutubeLikes).unwrap_or(&0.) - / (1. + *n.ratings.get(&Rating::YoutubeViews).unwrap_or(&0.)), + *n.ratings.get(&RatingType::YoutubeLikes).unwrap_or(&0.) + / (1. + *n.ratings.get(&RatingType::YoutubeViews).unwrap_or(&0.)), ) }), SortProperty::RatingUser => nodes.sort_by_cached_key(|(_, u)| u.rating), diff --git a/logic/src/home.rs b/logic/src/home.rs index ff85ba1..db8a397 100644 --- a/logic/src/home.rs +++ b/logic/src/home.rs @@ -7,7 +7,7 @@ use crate::{DATABASE, node::DatabaseNodeUserDataExt, session::Session}; use anyhow::{Context, Result}; use jellycommon::{ - NodeID, NodeKind, Rating, Visibility, + NodeID, NodeKind, RatingType, Visibility, api::ApiHomeResponse, chrono::{Datelike, Utc}, user::WatchedState, @@ -77,7 +77,7 @@ pub fn home(session: &Session) -> Result<ApiHomeResponse> { items.sort_by_key(|(n, _)| { n.ratings - .get(&Rating::Tmdb) + .get(&RatingType::Tmdb) .map(|x| (*x * -1000.) as i32) .unwrap_or(0) }); @@ -87,7 +87,7 @@ pub fn home(session: &Session) -> Result<ApiHomeResponse> { items .iter() .take(16) - .filter(|(n, _)| n.ratings.contains_key(&Rating::Tmdb)) + .filter(|(n, _)| n.ratings.contains_key(&RatingType::Tmdb)) .cloned() .collect(), )); |