aboutsummaryrefslogtreecommitdiff
path: root/pkg/database
diff options
context:
space:
mode:
authorGabriel Arakaki Giovanini <mail@gabrielgio.me>2023-07-18 21:41:53 +0200
committerGabriel Arakaki Giovanini <mail@gabrielgio.me>2023-07-18 21:41:53 +0200
commit69d71c2a495d9cce1984ba2ffddf1d98622b01fe (patch)
tree3abd105a970fe773c0b19cb0c4f974688001e5e0 /pkg/database
parent05a8dbf46792adfef007a0ffbcb654026db036fa (diff)
downloadlens-69d71c2a495d9cce1984ba2ffddf1d98622b01fe.tar.gz
lens-69d71c2a495d9cce1984ba2ffddf1d98622b01fe.tar.bz2
lens-69d71c2a495d9cce1984ba2ffddf1d98622b01fe.zip
feat: Move to user path media
Now media also base on user folder to fetch its media.
Diffstat (limited to 'pkg/database')
-rw-r--r--pkg/database/repository/media.go1
-rw-r--r--pkg/database/sql/media.go5
2 files changed, 4 insertions, 2 deletions
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").