Derive defaults for sorting enums, remove ordering from films SQL query
This commit is contained in:
parent
d6bac9ebea
commit
7127dd57c6
2 changed files with 18 additions and 20 deletions
|
@ -30,7 +30,6 @@ impl DataManager {
|
||||||
. prepare ( "
|
. prepare ( "
|
||||||
select uuid , name , original_name , release_date , runtime_minutes , poster_file_path
|
select uuid , name , original_name , release_date , runtime_minutes , poster_file_path
|
||||||
from films
|
from films
|
||||||
order by release_date desc
|
|
||||||
" ) ?
|
" ) ?
|
||||||
. query (()) ?
|
. query (()) ?
|
||||||
. map (row_to_film_overview)
|
. map (row_to_film_overview)
|
||||||
|
@ -126,7 +125,13 @@ fn row_to_series_overview ( row : & Row ) -> rusqlite :: Result <SeriesOverview>
|
||||||
. map ( PathBuf :: from ) ;
|
. map ( PathBuf :: from ) ;
|
||||||
let first_release_date = row . get (4) ? ;
|
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 {
|
impl From <Error> for ZoodexError {
|
||||||
|
|
|
@ -24,15 +24,21 @@ pub trait MediaSorting < P : MediaProperty > : Clone + Copy + Debug + Default {
|
||||||
|
|
||||||
pub trait MediaProperty : Clone + Copy + Debug + PartialEq {}
|
pub trait MediaProperty : Clone + Copy + Debug + PartialEq {}
|
||||||
|
|
||||||
# [ derive ( Clone , Copy , Debug , PartialEq ) ] pub enum FilmProperty { Name , ReleaseDate , Runtime }
|
# [ derive ( Clone , Copy , Debug , Default , PartialEq ) ] pub enum FilmProperty {
|
||||||
# [ derive ( Clone , Copy , Debug , PartialEq ) ] pub enum SeriesProperty { Name , FirstReleaseDate }
|
# [default] Name , ReleaseDate , Runtime ,
|
||||||
# [ derive ( Clone , Copy , Debug , PartialEq ) ] pub enum SortingDirection { Ascending , Descending }
|
}
|
||||||
|
# [ 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 ,
|
property : FilmProperty ,
|
||||||
direction : SortingDirection ,
|
direction : SortingDirection ,
|
||||||
}
|
}
|
||||||
# [ derive ( Clone , Copy , Debug ) ] pub struct SeriesSorting {
|
# [ derive ( Clone , Copy , Debug , Default ) ] pub struct SeriesSorting {
|
||||||
property : SeriesProperty ,
|
property : SeriesProperty ,
|
||||||
direction : SortingDirection ,
|
direction : SortingDirection ,
|
||||||
}
|
}
|
||||||
|
@ -52,19 +58,6 @@ impl MediaSorting <SeriesProperty> for SeriesSorting {
|
||||||
fn get_direction ( & self ) -> SortingDirection { self . direction }
|
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 FilmProperty {}
|
||||||
impl MediaProperty for SeriesProperty {}
|
impl MediaProperty for SeriesProperty {}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue