1
Fork 0

order root albums by path on settings page (#983)

Once you have more than a few paths assigned to a user, it becomes
quite hard to oversee the list.

Personally, I would add my albums to Photoview one by one, so I can
manage the processing better. For example, I can review and fix the face
recognition for one new album at a time, and I don't need to deal with
too much data.
Since I started to add the albums in a random order, it's relatively
hard to find which album is added and which is not.

An easy fix is to order the photo paths by their name.

- Extended the query of the rootAlbums to order them by path
This commit is contained in:
Lajos Koszti 2024-07-01 20:04:50 +02:00 committed by GitHub
parent df9af39a16
commit 10e9e354b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View File

@ -56,7 +56,7 @@ func (r *userResolver) RootAlbums(ctx context.Context, user *models.User) (album
db.Table("user_albums"). db.Table("user_albums").
Select("albums.id"). Select("albums.id").
Joins("JOIN albums ON albums.id = user_albums.album_id AND user_albums.user_id = ?", user.ID), Joins("JOIN albums ON albums.id = user_albums.album_id AND user_albums.user_id = ?", user.ID),
).Or("albums.parent_album_id IS NULL"). ).Or("albums.parent_album_id IS NULL").Order("path ASC").
Association("Albums").Find(&albums) Association("Albums").Find(&albums)
return return

View File

@ -55,7 +55,11 @@ func FindAlbumsForUser(db *gorm.DB, user *models.User, album_cache *scanner_cach
} }
var userRootAlbums []*models.Album var userRootAlbums []*models.Album
if err := db.Where("id IN (?)", userAlbumIDs).Where("parent_album_id IS NULL OR parent_album_id NOT IN (?)", userAlbumIDs).Find(&userRootAlbums).Error; err != nil { if err := db.
Where("id IN (?)", userAlbumIDs).
Where("parent_album_id IS NULL OR parent_album_id NOT IN (?)", userAlbumIDs).
Order("path ASC").
Find(&userRootAlbums).Error; err != nil {
return nil, []error{err} return nil, []error{err}
} }