mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 08:26:00 +01:00
Fix gallery scrubber image order (#5222)
This commit is contained in:
parent
601a16b5cb
commit
8c2a25b833
1 changed files with 7 additions and 4 deletions
|
|
@ -602,6 +602,11 @@ func (qb *ImageStore) FindByChecksum(ctx context.Context, checksum string) ([]*m
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var defaultGalleryOrder = []exp.OrderedExpression{
|
||||||
|
goqu.L("COALESCE(folders.path, '') || COALESCE(files.basename, '') COLLATE NATURAL_CI").Asc(),
|
||||||
|
goqu.L("COALESCE(images.title, images.id) COLLATE NATURAL_CI").Asc(),
|
||||||
|
}
|
||||||
|
|
||||||
func (qb *ImageStore) FindByGalleryID(ctx context.Context, galleryID int) ([]*models.Image, error) {
|
func (qb *ImageStore) FindByGalleryID(ctx context.Context, galleryID int) ([]*models.Image, error) {
|
||||||
table := qb.table()
|
table := qb.table()
|
||||||
|
|
||||||
|
|
@ -618,7 +623,7 @@ func (qb *ImageStore) FindByGalleryID(ctx context.Context, galleryID int) ([]*mo
|
||||||
table.Col(idColumn).Eq(
|
table.Col(idColumn).Eq(
|
||||||
sq,
|
sq,
|
||||||
),
|
),
|
||||||
).Order(goqu.L("COALESCE(folders.path, '') || COALESCE(files.basename, '') COLLATE NATURAL_CI").Asc())
|
).Order(defaultGalleryOrder...)
|
||||||
|
|
||||||
ret, err := qb.getMany(ctx, q)
|
ret, err := qb.getMany(ctx, q)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -630,8 +635,6 @@ func (qb *ImageStore) FindByGalleryID(ctx context.Context, galleryID int) ([]*mo
|
||||||
|
|
||||||
func (qb *ImageStore) FindByGalleryIDIndex(ctx context.Context, galleryID int, index uint) (*models.Image, error) {
|
func (qb *ImageStore) FindByGalleryIDIndex(ctx context.Context, galleryID int, index uint) (*models.Image, error) {
|
||||||
table := qb.table()
|
table := qb.table()
|
||||||
fileTable := fileTableMgr.table
|
|
||||||
folderTable := folderTableMgr.table
|
|
||||||
|
|
||||||
q := qb.selectDataset().
|
q := qb.selectDataset().
|
||||||
InnerJoin(
|
InnerJoin(
|
||||||
|
|
@ -640,7 +643,7 @@ func (qb *ImageStore) FindByGalleryIDIndex(ctx context.Context, galleryID int, i
|
||||||
).
|
).
|
||||||
Where(galleriesImagesJoinTable.Col(galleryIDColumn).Eq(galleryID)).
|
Where(galleriesImagesJoinTable.Col(galleryIDColumn).Eq(galleryID)).
|
||||||
Prepared(true).
|
Prepared(true).
|
||||||
Order(folderTable.Col("path").Asc(), fileTable.Col("basename").Asc()).
|
Order(defaultGalleryOrder...).
|
||||||
Limit(1).Offset(index)
|
Limit(1).Offset(index)
|
||||||
|
|
||||||
ret, err := qb.getMany(ctx, q)
|
ret, err := qb.getMany(ctx, q)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue