Commit 09bc0308 authored by Jian Li's avatar Jian Li Committed by Jian Li
Browse files

in sortRequest add one flag to keep all the logic in the switch

parent 079fbeac
Pipeline #12009 passed with stage
in 21 minutes and 3 seconds
......@@ -886,6 +886,7 @@ std::string Media::sortRequest( const QueryParameters* params )
auto sort = params != nullptr ? params->sort : SortingCriteria::Default;
auto desc = params != nullptr ? params->desc : false;
auto descAdded = false;
switch ( sort )
{
case SortingCriteria::Duration:
......@@ -915,6 +916,7 @@ std::string Media::sortRequest( const QueryParameters* params )
req += "alb.title DESC, att.track_number";
else
req += "alb.title, att.track_number";
descAdded = true;
break;
case SortingCriteria::Artist:
req += "art.name";
......@@ -924,6 +926,7 @@ std::string Media::sortRequest( const QueryParameters* params )
req += "alb.title, att.track_number DESC, att.disc_number";
else
req += "alb.title, att.track_number, att.disc_number";
descAdded = true;
break;
default:
LOG_WARN( "Unsupported sorting criteria, falling back to SortingCriteria::Default (Alpha)" );
......@@ -933,8 +936,7 @@ std::string Media::sortRequest( const QueryParameters* params )
req += "m.title";
break;
}
if ( desc == true && sort != SortingCriteria::Album &&
sort != SortingCriteria::TrackId )
if ( desc == true && !descAdded )
req += " DESC";
return req;
}
......
Supports Markdown
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