From a87e03ac1b777be4169f0d27c69e17505d96802b Mon Sep 17 00:00:00 2001 From: Gabriel Arakaki Giovanini Date: Sun, 1 Oct 2023 14:57:52 +0200 Subject: fix: Oder by correct field Before the order was not taking the `date_shot` into consideration. --- pkg/database/sql/media.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'pkg/database/sql') 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 { -- cgit v1.2.3