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

Artist: Use Album as default order for tracks

parent dded3df8
Pipeline #6435 passed with stage
in 5 minutes and 28 seconds
......@@ -112,7 +112,10 @@ Query<IMedia> Artist::tracks( const QueryParameters* params ) const
if ( m_id != VariousArtistID )
{
req += "INNER JOIN MediaArtistRelation mar ON mar.media_id = med.id_media ";
if ( sort == SortingCriteria::Album )
if ( sort != SortingCriteria::Duration &&
sort != SortingCriteria::InsertionDate &&
sort != SortingCriteria::ReleaseDate &&
sort != SortingCriteria::Alpha )
{
req += "INNER JOIN Album alb ON alb.id_album = atr.album_id "
"INNER JOIN AlbumTrack atr ON atr.media_id = med.id_media ";
......@@ -139,18 +142,18 @@ Query<IMedia> Artist::tracks( const QueryParameters* params ) const
case SortingCriteria::ReleaseDate:
orderBy += "med.release_date";
break;
case SortingCriteria::Album:
if ( desc == true )
orderBy += "alb.title DESC, atr.disc_number, atr.track_number";
else
orderBy += "alb.title, atr.disc_number, atr.track_number";
case SortingCriteria::Alpha:
orderBy += "med.title";
break;
default:
LOG_WARN( "Unsupported sorting criteria, falling back to SortingCriteria::Default (Alpha)" );
/* fall-through */
case SortingCriteria::Album:
case SortingCriteria::Default:
case SortingCriteria::Alpha:
orderBy += "med.title";
if ( desc == true )
orderBy += "alb.title DESC, atr.disc_number, atr.track_number";
else
orderBy += "alb.title, atr.disc_number, atr.track_number";
break;
}
......
......@@ -194,13 +194,16 @@ TEST_F( Artists, AllSongs )
ASSERT_TRUE( res );
}
auto songs = artist->tracks( nullptr )->all();
QueryParameters params;
params.sort = SortingCriteria::Alpha;
params.desc = false;
auto songs = artist->tracks( &params )->all();
ASSERT_EQ( songs.size(), 3u );
Reload();
auto artist2 = ml->artist( artist->id() );
songs = artist2->tracks( nullptr )->all();
songs = artist2->tracks( &params )->all();
ASSERT_EQ( songs.size(), 3u );
}
......
......@@ -323,7 +323,10 @@ TEST_F( DeviceFs, RemoveArtist )
ASSERT_EQ( 1u, artists.size() );
auto tracks = artist->tracks( nullptr )->all();
QueryParameters params;
params.sort = SortingCriteria::Alpha;
params.desc = false;
auto tracks = artist->tracks( &params )->all();
ASSERT_EQ( 3u, tracks.size() );
auto device = fsMock->removeDevice( RemovableDeviceUuid );
......@@ -339,7 +342,7 @@ TEST_F( DeviceFs, RemoveArtist )
// But we expect the tracks count to be down
artist = std::static_pointer_cast<Artist>( ml->artist( artist->id() ) );
tracks = artist->tracks( nullptr )->all();
tracks = artist->tracks( &params )->all();
ASSERT_EQ( 1u, tracks.size() );
// Now check that everything appears again when we plug the device back in
......
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