Derive defaults for sorting enums, remove ordering from films SQL query

This commit is contained in:
Reinout Meliesie 2025-02-11 00:20:29 +01:00
parent d6bac9ebea
commit 7127dd57c6
Signed by: zedfrigg
GPG key ID: 3AFCC06481308BC6
2 changed files with 18 additions and 20 deletions

View file

@ -30,7 +30,6 @@ impl DataManager {
. prepare ( "
select uuid , name , original_name , release_date , runtime_minutes , poster_file_path
from films
order by release_date desc
" ) ?
. query (()) ?
. map (row_to_film_overview)
@ -126,7 +125,13 @@ fn row_to_series_overview ( row : & Row ) -> rusqlite :: Result <SeriesOverview>
. map ( PathBuf :: from ) ;
let first_release_date = row . get (4) ? ;
Ok ( SeriesOverview { uuid , name , original_name , first_release_date , poster_file_path } )
Ok ( SeriesOverview {
uuid ,
name ,
original_name ,
first_release_date ,
poster_file_path ,
} )
}
impl From <Error> for ZoodexError {

View file

@ -24,15 +24,21 @@ pub trait MediaSorting < P : MediaProperty > : Clone + Copy + Debug + Default {
pub trait MediaProperty : Clone + Copy + Debug + PartialEq {}
# [ derive ( Clone , Copy , Debug , PartialEq ) ] pub enum FilmProperty { Name , ReleaseDate , Runtime }
# [ derive ( Clone , Copy , Debug , PartialEq ) ] pub enum SeriesProperty { Name , FirstReleaseDate }
# [ derive ( Clone , Copy , Debug , PartialEq ) ] pub enum SortingDirection { Ascending , Descending }
# [ derive ( Clone , Copy , Debug , Default , PartialEq ) ] pub enum FilmProperty {
# [default] Name , ReleaseDate , Runtime ,
}
# [ derive ( Clone , Copy , Debug , Default , PartialEq ) ] pub enum SeriesProperty {
# [default] Name , FirstReleaseDate ,
}
# [ derive ( Clone , Copy , Debug , Default , PartialEq ) ] pub enum SortingDirection {
# [default] Ascending , Descending ,
}
# [ derive ( Clone , Copy , Debug ) ] pub struct FilmsSorting {
# [ derive ( Clone , Copy , Debug , Default ) ] pub struct FilmsSorting {
property : FilmProperty ,
direction : SortingDirection ,
}
# [ derive ( Clone , Copy , Debug ) ] pub struct SeriesSorting {
# [ derive ( Clone , Copy , Debug , Default ) ] pub struct SeriesSorting {
property : SeriesProperty ,
direction : SortingDirection ,
}
@ -52,19 +58,6 @@ impl MediaSorting <SeriesProperty> for SeriesSorting {
fn get_direction ( & self ) -> SortingDirection { self . direction }
}
impl Default for FilmsSorting {
fn default () -> Self { Self {
property : FilmProperty :: Name ,
direction : SortingDirection :: Ascending ,
} }
}
impl Default for SeriesSorting {
fn default () -> Self { Self {
property : SeriesProperty :: Name ,
direction : SortingDirection :: Ascending ,
} }
}
impl MediaProperty for FilmProperty {}
impl MediaProperty for SeriesProperty {}