Albums: Use most recent photo with best quality as cover
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
parent
95cc4ec43f
commit
d5490c0364
1 changed files with 3 additions and 3 deletions
|
@ -39,11 +39,11 @@ func (q *Query) AlbumByUUID(albumUUID string) (album entity.Album, err error) {
|
|||
|
||||
// AlbumThumbByUUID returns a album preview file based on the uuid.
|
||||
func (q *Query) AlbumThumbByUUID(albumUUID string) (file entity.File, err error) {
|
||||
// q.db.LogMode(true)
|
||||
|
||||
if err := q.db.Where("files.file_primary AND files.deleted_at IS NULL").
|
||||
if err := q.db.Where("files.file_primary = 1 AND files.deleted_at IS NULL").
|
||||
Joins("JOIN albums ON albums.album_uuid = ?", albumUUID).
|
||||
Joins("JOIN photos_albums pa ON pa.album_uuid = albums.album_uuid AND pa.photo_uuid = files.photo_uuid").
|
||||
Joins("JOIN photos ON photos.id = files.photo_id AND photos.deleted_at IS NULL").
|
||||
Order("photos.photo_quality DESC, photos.taken_at DESC").
|
||||
First(&file).Error; err != nil {
|
||||
return file, err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue