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
commit 7127dd57c6
Signed by: zedfrigg
GPG key ID: 3AFCC06481308BC6
2 changed files with 18 additions and 20 deletions

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 {}