Commit fbfaa911 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Artist: When sorting by album descending, don't invert tracks ordering

parent 11965aa9
......@@ -138,7 +138,7 @@ Query<IMedia> Artist::tracks( const QueryParameters* params ) const
break;
case SortingCriteria::Album:
if ( desc == true )
orderBy += "atr.album_id DESC, atr.disc_number DESC, atr.track_number";
orderBy += "atr.album_id DESC, atr.disc_number, atr.track_number";
else
orderBy += "atr.album_id, atr.disc_number, atr.track_number";
break;
......@@ -147,7 +147,7 @@ Query<IMedia> Artist::tracks( const QueryParameters* params ) const
break;
}
if ( desc == true )
if ( desc == true && sort != SortingCriteria::Album )
orderBy += " DESC";
return make_query<Media, IMedia>( m_ml, "med.*", std::move( req ),
std::move( orderBy ), m_id );
......
......@@ -373,10 +373,10 @@ TEST_F( Artists, SortMediaByAlbum )
params.desc = true;
tracks = artist->tracks( &params )->all();
ASSERT_EQ( 4u, tracks.size() );
ASSERT_EQ( "alb1_song2.mp3", tracks[0]->title() );
ASSERT_EQ( "alb1_song1.mp3", tracks[1]->title() );
ASSERT_EQ( "alb0_song2.mp3", tracks[2]->title() );
ASSERT_EQ( "alb0_song1.mp3", tracks[3]->title() );
ASSERT_EQ( "alb1_song1.mp3", tracks[0]->title() );
ASSERT_EQ( "alb1_song2.mp3", tracks[1]->title() );
ASSERT_EQ( "alb0_song1.mp3", tracks[2]->title() );
ASSERT_EQ( "alb0_song2.mp3", tracks[3]->title() );
}
TEST_F( Artists, SortAlbum )
......@@ -532,12 +532,13 @@ TEST_F( Artists, SortTracksMultiDisc )
params.desc = true;
tracks = artist->tracks( &params )->all();
ASSERT_EQ( media[5]->id(), tracks[0]->id() );
ASSERT_EQ( media[3]->id(), tracks[1]->id() );
ASSERT_EQ( media[1]->id(), tracks[2]->id() );
ASSERT_EQ( media[4]->id(), tracks[3]->id() );
ASSERT_EQ( media[2]->id(), tracks[4]->id() );
ASSERT_EQ( media[0]->id(), tracks[5]->id() );
// Ordering by album doesn't invert tracks ordering (anymore)
ASSERT_EQ( media[0]->id(), tracks[0]->id() );
ASSERT_EQ( media[2]->id(), tracks[1]->id() );
ASSERT_EQ( media[4]->id(), tracks[2]->id() );
ASSERT_EQ( media[1]->id(), tracks[3]->id() );
ASSERT_EQ( media[3]->id(), tracks[4]->id() );
ASSERT_EQ( media[5]->id(), tracks[5]->id() );
}
TEST_F( Artists, Query )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment