mirror of https://github.com/stashapp/stash.git
Order gallery images by path (#2390)
This commit is contained in:
parent
6ceb9c73dd
commit
e4ad42caf0
|
@ -26,7 +26,10 @@ func (r *galleryResolver) Title(ctx context.Context, obj *models.Gallery) (*stri
|
|||
func (r *galleryResolver) Images(ctx context.Context, obj *models.Gallery) (ret []*models.Image, err error) {
|
||||
if err := r.withReadTxn(ctx, func(repo models.ReaderRepository) error {
|
||||
var err error
|
||||
ret, err = repo.Image().FindByGalleryID(obj.ID)
|
||||
|
||||
// #2376 - sort images by path
|
||||
ret, err = image.FindByGalleryID(repo.Image(), obj.ID, "path", models.SortDirectionEnumAsc)
|
||||
|
||||
return err
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
|
@ -37,7 +40,7 @@ func (r *galleryResolver) Images(ctx context.Context, obj *models.Gallery) (ret
|
|||
|
||||
func (r *galleryResolver) Cover(ctx context.Context, obj *models.Gallery) (ret *models.Image, err error) {
|
||||
if err := r.withReadTxn(ctx, func(repo models.ReaderRepository) error {
|
||||
imgs, err := repo.Image().FindByGalleryID(obj.ID)
|
||||
imgs, err := image.FindByGalleryID(repo.Image(), obj.ID, "", "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -68,3 +68,26 @@ func CountByTagID(r models.ImageReader, id int) (int, error) {
|
|||
|
||||
return r.QueryCount(filter, nil)
|
||||
}
|
||||
|
||||
func FindByGalleryID(r models.ImageReader, galleryID int, sortBy string, sortDir models.SortDirectionEnum) ([]*models.Image, error) {
|
||||
perPage := -1
|
||||
|
||||
findFilter := models.FindFilterType{
|
||||
PerPage: &perPage,
|
||||
}
|
||||
|
||||
if sortBy != "" {
|
||||
findFilter.Sort = &sortBy
|
||||
}
|
||||
|
||||
if sortDir.IsValid() {
|
||||
findFilter.Direction = &sortDir
|
||||
}
|
||||
|
||||
return Query(r, &models.ImageFilterType{
|
||||
Galleries: &models.MultiCriterionInput{
|
||||
Value: []string{strconv.Itoa(galleryID)},
|
||||
Modifier: models.CriterionModifierIncludes,
|
||||
},
|
||||
}, &findFilter)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue