mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 08:26:00 +01:00
Correct title ordering for objects without titles (#3244)
* Correct scene title ordering * Correct ordering for other objects * Add basename function, add to gallery title sort
This commit is contained in:
parent
78bb2d8425
commit
eb7956a05a
7 changed files with 17 additions and 3 deletions
|
|
@ -428,6 +428,7 @@ func registerCustomDriver() {
|
||||||
funcs := map[string]interface{}{
|
funcs := map[string]interface{}{
|
||||||
"regexp": regexFn,
|
"regexp": regexFn,
|
||||||
"durationToTinyInt": durationToTinyIntFn,
|
"durationToTinyInt": durationToTinyIntFn,
|
||||||
|
"basename": basenameFn,
|
||||||
}
|
}
|
||||||
|
|
||||||
for name, fn := range funcs {
|
for name, fn := range funcs {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package sqlite
|
package sqlite
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
@ -30,3 +31,7 @@ func durationToTinyIntFn(str string) (int64, error) {
|
||||||
|
|
||||||
return int64(seconds), nil
|
return int64(seconds), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func basenameFn(str string) (string, error) {
|
||||||
|
return filepath.Base(str), nil
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1109,7 +1109,7 @@ func (qb *GalleryStore) setGallerySort(query *queryBuilder, findFilter *models.F
|
||||||
case "title":
|
case "title":
|
||||||
addFileTable()
|
addFileTable()
|
||||||
addFolderTable()
|
addFolderTable()
|
||||||
query.sortAndPagination += " ORDER BY galleries.title COLLATE NATURAL_CS " + direction + ", folders.path " + direction + ", file_folder.path " + direction + ", files.basename COLLATE NATURAL_CS " + direction
|
query.sortAndPagination += " ORDER BY COALESCE(galleries.title, files.basename, basename(COALESCE(folders.path, ''))) COLLATE NATURAL_CS " + direction + ", file_folder.path " + direction
|
||||||
default:
|
default:
|
||||||
query.sortAndPagination += getSort(sort, direction, "galleries")
|
query.sortAndPagination += getSort(sort, direction, "galleries")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2414,6 +2414,13 @@ func TestGalleryQuerySorting(t *testing.T) {
|
||||||
-1,
|
-1,
|
||||||
-1,
|
-1,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"title",
|
||||||
|
"title",
|
||||||
|
models.SortDirectionEnumDesc,
|
||||||
|
-1,
|
||||||
|
-1,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
qb := db.Gallery
|
qb := db.Gallery
|
||||||
|
|
|
||||||
|
|
@ -1019,7 +1019,7 @@ func (qb *ImageStore) setImageSortAndPagination(q *queryBuilder, findFilter *mod
|
||||||
case "title":
|
case "title":
|
||||||
addFilesJoin()
|
addFilesJoin()
|
||||||
addFolderJoin()
|
addFolderJoin()
|
||||||
sortClause = " ORDER BY images.title COLLATE NATURAL_CS " + direction + ", folders.path " + direction + ", files.basename COLLATE NATURAL_CS " + direction
|
sortClause = " ORDER BY COALESCE(images.title, files.basename) COLLATE NATURAL_CS " + direction + ", folders.path " + direction
|
||||||
default:
|
default:
|
||||||
sortClause = getSort(sort, direction, "images")
|
sortClause = getSort(sort, direction, "images")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1446,7 +1446,7 @@ func (qb *SceneStore) setSceneSort(query *queryBuilder, findFilter *models.FindF
|
||||||
case "title":
|
case "title":
|
||||||
addFileTable()
|
addFileTable()
|
||||||
addFolderTable()
|
addFolderTable()
|
||||||
query.sortAndPagination += " ORDER BY scenes.title COLLATE NATURAL_CS " + direction + ", folders.path " + direction + ", files.basename COLLATE NATURAL_CS " + direction
|
query.sortAndPagination += " ORDER BY COALESCE(scenes.title, files.basename) COLLATE NATURAL_CS " + direction + ", folders.path " + direction
|
||||||
case "play_count":
|
case "play_count":
|
||||||
// handle here since getSort has special handling for _count suffix
|
// handle here since getSort has special handling for _count suffix
|
||||||
query.sortAndPagination += " ORDER BY scenes.play_count " + direction
|
query.sortAndPagination += " ORDER BY scenes.play_count " + direction
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
* Changed performer aliases to be a list, rather than a string field. ([#3113](https://github.com/stashapp/stash/pull/3113))
|
* Changed performer aliases to be a list, rather than a string field. ([#3113](https://github.com/stashapp/stash/pull/3113))
|
||||||
|
|
||||||
### 🐛 Bug fixes
|
### 🐛 Bug fixes
|
||||||
|
* Fixed objects without titles not being sorted correctly with objects with titles. ([#3244](https://github.com/stashapp/stash/pull/3244))
|
||||||
* Fixed incorrect new Performer pill being removed when creating Performer from scrape dialog. ([#3251](https://github.com/stashapp/stash/pull/3251))
|
* Fixed incorrect new Performer pill being removed when creating Performer from scrape dialog. ([#3251](https://github.com/stashapp/stash/pull/3251))
|
||||||
* Fixed date fields not being nulled correctly when cleared. ([#3243](https://github.com/stashapp/stash/pull/3243))
|
* Fixed date fields not being nulled correctly when cleared. ([#3243](https://github.com/stashapp/stash/pull/3243))
|
||||||
* Fixed scene wall items to show file base name where scene has no title set. ([#3242](https://github.com/stashapp/stash/pull/3242))
|
* Fixed scene wall items to show file base name where scene has no title set. ([#3242](https://github.com/stashapp/stash/pull/3242))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue