From 69d71c2a495d9cce1984ba2ffddf1d98622b01fe Mon Sep 17 00:00:00 2001 From: Gabriel Arakaki Giovanini Date: Tue, 18 Jul 2023 21:41:53 +0200 Subject: feat: Move to user path media Now media also base on user folder to fetch its media. --- pkg/database/repository/media.go | 1 + pkg/database/sql/media.go | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'pkg/database') diff --git a/pkg/database/repository/media.go b/pkg/database/repository/media.go index 6ab4ee6..6f5b39b 100644 --- a/pkg/database/repository/media.go +++ b/pkg/database/repository/media.go @@ -41,6 +41,7 @@ type ( Pagination struct { Page int Size int + Path string } CreateMedia struct { diff --git a/pkg/database/sql/media.go b/pkg/database/sql/media.go index b8203f3..e5ba517 100644 --- a/pkg/database/sql/media.go +++ b/pkg/database/sql/media.go @@ -139,6 +139,7 @@ func (self *MediaRepository) List(ctx context.Context, pagination *repository.Pa Model(&Media{}). Offset(pagination.Page * pagination.Size). Limit(pagination.Size). + Where("path like '" + pagination.Path + "%'"). Order("created_at DESC"). Find(&medias) @@ -257,7 +258,7 @@ func (r *MediaRepository) ListEmptyEXIF(ctx context.Context, pagination *reposit WithContext(ctx). Model(&Media{}). Joins("left join media_exifs on media.id = media_exifs.media_id"). - Where("media_exifs.media_id IS NULL"). + Where("media_exifs.media_id IS NULL AND media.path like '" + pagination.Path + "%'"). Offset(pagination.Page * pagination.Size). Limit(pagination.Size). Order("media.created_at DESC"). @@ -280,7 +281,7 @@ func (r *MediaRepository) ListEmptyThumbnail(ctx context.Context, pagination *re WithContext(ctx). Model(&Media{}). Joins("left join media_thumbnails on media.id = media_thumbnails.media_id"). - Where("media_thumbnails.media_id IS NULL"). + Where("media_thumbnails.media_id IS NULL AND media.path like '" + pagination.Path + "%'"). Offset(pagination.Page * pagination.Size). Limit(pagination.Size). Order("media.created_at DESC"). -- cgit v1.2.3