aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Arakaki Giovanini <mail@gabrielgio.me>2023-10-01 14:57:52 +0200
committerGabriel Arakaki Giovanini <mail@gabrielgio.me>2023-10-01 14:57:52 +0200
commita87e03ac1b777be4169f0d27c69e17505d96802b (patch)
treeb78a8d5a7b79d773e93a6677d6636d7eefec4d66
parent4bc07694269c17f6d915ae084aba1b0814e02dff (diff)
downloadlens-a87e03ac1b777be4169f0d27c69e17505d96802b.tar.gz
lens-a87e03ac1b777be4169f0d27c69e17505d96802b.tar.bz2
lens-a87e03ac1b777be4169f0d27c69e17505d96802b.zip
fix: Oder by correct field
Before the order was not taking the `date_shot` into consideration.
-rw-r--r--pkg/database/sql/media.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/pkg/database/sql/media.go b/pkg/database/sql/media.go
index b13e267..16769bf 100644
--- a/pkg/database/sql/media.go
+++ b/pkg/database/sql/media.go
@@ -164,7 +164,8 @@ func (self *MediaRepository) List(ctx context.Context, pagination *repository.Pa
Offset(pagination.Page * pagination.Size).
Limit(pagination.Size).
Where("path like '" + pagination.Path + "%'").
- Order("created_at DESC").
+ Order("COALESCE (media_exifs.date_shot, media.created_at) DESC").
+ InnerJoins("INNER JOIN media_exifs ON media_exifs.media_id = media.id").
Find(&medias)
if result.Error != nil {