mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 20:34:37 +03:00
Fix movies sorting, scene studio editing (#1478)
* Fix movies:sort_by->scenes_count, scene:edit->remove studio
This commit is contained in:
@@ -210,12 +210,14 @@ func (qb *movieQueryBuilder) getMovieSort(findFilter *models.FindFilterType) str
|
||||
direction = findFilter.GetDirection()
|
||||
}
|
||||
|
||||
// #943 - override name sorting to use natural sort
|
||||
if sort == "name" {
|
||||
switch sort {
|
||||
case "name": // #943 - override name sorting to use natural sort
|
||||
return " ORDER BY " + getColumn("movies", sort) + " COLLATE NATURAL_CS " + direction
|
||||
case "scenes_count": // generic getSort won't work for this
|
||||
return getCountSort(movieTable, moviesScenesTable, movieIDColumn, direction)
|
||||
default:
|
||||
return getSort(sort, direction, "movies")
|
||||
}
|
||||
|
||||
return getSort(sort, direction, "movies")
|
||||
}
|
||||
|
||||
func (qb *movieQueryBuilder) queryMovie(query string, args []interface{}) (*models.Movie, error) {
|
||||
|
||||
@@ -186,6 +186,35 @@ func queryMovie(t *testing.T, sqb models.MovieReader, movieFilter *models.MovieF
|
||||
return movies
|
||||
}
|
||||
|
||||
func TestMovieQuerySorting(t *testing.T) {
|
||||
sort := "scenes_count"
|
||||
direction := models.SortDirectionEnumDesc
|
||||
findFilter := models.FindFilterType{
|
||||
Sort: &sort,
|
||||
Direction: &direction,
|
||||
}
|
||||
|
||||
withTxn(func(r models.Repository) error {
|
||||
sqb := r.Movie()
|
||||
movies := queryMovie(t, sqb, nil, &findFilter)
|
||||
|
||||
// scenes should be in same order as indexes
|
||||
firstMovie := movies[0]
|
||||
|
||||
assert.Equal(t, movieIDs[movieIdxWithScene], firstMovie.ID)
|
||||
|
||||
// sort in descending order
|
||||
direction = models.SortDirectionEnumAsc
|
||||
|
||||
movies = queryMovie(t, sqb, nil, &findFilter)
|
||||
lastMovie := movies[len(movies)-1]
|
||||
|
||||
assert.Equal(t, movieIDs[movieIdxWithScene], lastMovie.ID)
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func TestMovieUpdateMovieImages(t *testing.T) {
|
||||
if err := withTxn(func(r models.Repository) error {
|
||||
mqb := r.Movie()
|
||||
|
||||
Reference in New Issue
Block a user