feat(legacy): order by filename when lptime is null (#3069)

### Description

It is good to have a deterministic order when doing explicit file
sorting. This sorts by filename when last played time is null. I would
expect filename to be the next sort after last played time in case of a
tie, and was surprised to find it was not explicit. It should not break
any existing use cases.

**This is a new feature**:

Kind of?

**I have updated the documentation to reflect these changes**:

I did not update any documentation as this way seems like the logical
expected way to do the sort.

### Testing Notes

**What I did:**

I loaded up some tracks into a local libretime instance, let some of
them play, and tested that all the old sorts worked as before as well as
tracks getting sorted by filepath in case of a last played time
This commit is contained in:
dakriy 2024-08-23 23:47:25 -07:00 committed by GitHub
parent c883d0f2d5
commit 8c26505622
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 5 deletions

View File

@ -1633,12 +1633,10 @@ SQL;
$qry->addDescendingOrderByColumn('utime');
} elseif ($sortTracks == 'oldest') {
$qry->addAscendingOrderByColumn('utime');
}
// these sort additions are needed to override the default postgres NULL sort behavior
elseif ($sortTracks == 'mostrecentplay') {
$qry->addDescendingOrderByColumn('(lptime IS NULL), lptime');
} elseif ($sortTracks == 'mostrecentplay') {
$qry->addAscendingOrderByColumn('lptime DESC NULLS LAST, filepath');
} elseif ($sortTracks == 'leastrecentplay') {
$qry->addAscendingOrderByColumn('(lptime IS NOT NULL), lptime');
$qry->addAscendingOrderByColumn('lptime ASC NULLS FIRST, filepath');
} elseif ($sortTracks == 'random') {
$qry->addAscendingOrderByColumn('random()');
} else {