diff --git a/internal/api/album.go b/internal/api/album.go index 5a1b68b55..8308a3930 100644 --- a/internal/api/album.go +++ b/internal/api/album.go @@ -14,7 +14,7 @@ import ( "github.com/photoprism/photoprism/internal/event" "github.com/photoprism/photoprism/internal/form" "github.com/photoprism/photoprism/internal/photoprism" - "github.com/photoprism/photoprism/internal/repo" + "github.com/photoprism/photoprism/internal/query" "github.com/gin-gonic/gin" "github.com/gin-gonic/gin/binding" @@ -27,7 +27,7 @@ func GetAlbums(router *gin.RouterGroup, conf *config.Config) { router.GET("/albums", func(c *gin.Context) { var f form.AlbumSearch - r := repo.New(conf.OriginalsPath(), conf.Db()) + q := query.New(conf.OriginalsPath(), conf.Db()) err := c.MustBindWith(&f, binding.Form) if err != nil { @@ -35,7 +35,7 @@ func GetAlbums(router *gin.RouterGroup, conf *config.Config) { return } - result, err := r.Albums(f) + result, err := q.Albums(f) if err != nil { c.AbortWithStatusJSON(400, gin.H{"error": util.UcFirst(err.Error())}) return @@ -52,8 +52,8 @@ func GetAlbums(router *gin.RouterGroup, conf *config.Config) { func GetAlbum(router *gin.RouterGroup, conf *config.Config) { router.GET("/albums/:uuid", func(c *gin.Context) { id := c.Param("uuid") - r := repo.New(conf.OriginalsPath(), conf.Db()) - m, err := r.FindAlbumByUUID(id) + q := query.New(conf.OriginalsPath(), conf.Db()) + m, err := q.FindAlbumByUUID(id) if err != nil { c.AbortWithStatusJSON(404, gin.H{"error": util.UcFirst(err.Error())}) @@ -120,9 +120,9 @@ func UpdateAlbum(router *gin.RouterGroup, conf *config.Config) { } id := c.Param("uuid") - r := repo.New(conf.OriginalsPath(), conf.Db()) + q := query.New(conf.OriginalsPath(), conf.Db()) - m, err := r.FindAlbumByUUID(id) + m, err := q.FindAlbumByUUID(id) if err != nil { c.AbortWithStatusJSON(404, gin.H{"error": util.UcFirst(err.Error())}) @@ -148,9 +148,9 @@ func DeleteAlbum(router *gin.RouterGroup, conf *config.Config) { } id := c.Param("uuid") - r := repo.New(conf.OriginalsPath(), conf.Db()) + q := query.New(conf.OriginalsPath(), conf.Db()) - m, err := r.FindAlbumByUUID(id) + m, err := q.FindAlbumByUUID(id) if err != nil { c.AbortWithStatusJSON(404, gin.H{"error": util.UcFirst(err.Error())}) @@ -177,9 +177,9 @@ func LikeAlbum(router *gin.RouterGroup, conf *config.Config) { return } - r := repo.New(conf.OriginalsPath(), conf.Db()) + q := query.New(conf.OriginalsPath(), conf.Db()) - album, err := r.FindAlbumByUUID(c.Param("uuid")) + album, err := q.FindAlbumByUUID(c.Param("uuid")) if err != nil { c.AbortWithStatusJSON(404, gin.H{"error": util.UcFirst(err.Error())}) @@ -206,8 +206,8 @@ func DislikeAlbum(router *gin.RouterGroup, conf *config.Config) { return } - r := repo.New(conf.OriginalsPath(), conf.Db()) - album, err := r.FindAlbumByUUID(c.Param("uuid")) + q := query.New(conf.OriginalsPath(), conf.Db()) + album, err := q.FindAlbumByUUID(c.Param("uuid")) if err != nil { c.AbortWithStatusJSON(404, gin.H{"error": util.UcFirst(err.Error())}) @@ -244,8 +244,8 @@ func AddPhotosToAlbum(router *gin.RouterGroup, conf *config.Config) { return } - r := repo.New(conf.OriginalsPath(), conf.Db()) - a, err := r.FindAlbumByUUID(c.Param("uuid")) + q := query.New(conf.OriginalsPath(), conf.Db()) + a, err := q.FindAlbumByUUID(c.Param("uuid")) if err != nil { c.AbortWithStatusJSON(404, gin.H{"error": util.UcFirst(err.Error())}) @@ -257,7 +257,7 @@ func AddPhotosToAlbum(router *gin.RouterGroup, conf *config.Config) { var failed []string for _, photoUUID := range f.Photos { - if p, err := r.FindPhotoByUUID(photoUUID); err != nil { + if p, err := q.FindPhotoByUUID(photoUUID); err != nil { failed = append(failed, photoUUID) } else { added = append(added, entity.NewPhotoAlbum(p.PhotoUUID, a.AlbumUUID).FirstOrCreate(db)) @@ -295,8 +295,8 @@ func RemovePhotosFromAlbum(router *gin.RouterGroup, conf *config.Config) { return } - r := repo.New(conf.OriginalsPath(), conf.Db()) - a, err := r.FindAlbumByUUID(c.Param("uuid")) + q := query.New(conf.OriginalsPath(), conf.Db()) + a, err := q.FindAlbumByUUID(c.Param("uuid")) if err != nil { c.AbortWithStatusJSON(404, gin.H{"error": util.UcFirst(err.Error())}) @@ -319,15 +319,15 @@ func DownloadAlbum(router *gin.RouterGroup, conf *config.Config) { start := time.Now() - r := repo.New(conf.OriginalsPath(), conf.Db()) - a, err := r.FindAlbumByUUID(c.Param("uuid")) + q := query.New(conf.OriginalsPath(), conf.Db()) + a, err := q.FindAlbumByUUID(c.Param("uuid")) if err != nil { c.AbortWithStatusJSON(404, gin.H{"error": util.UcFirst(err.Error())}) return } - p, err := r.Photos(form.PhotoSearch{ + p, err := q.Photos(form.PhotoSearch{ Album: a.AlbumUUID, Count: 10000, Offset: 0, @@ -419,9 +419,9 @@ func AlbumThumbnail(router *gin.RouterGroup, conf *config.Config) { return } - r := repo.New(conf.OriginalsPath(), conf.Db()) + q := query.New(conf.OriginalsPath(), conf.Db()) - file, err := r.FindAlbumThumbByUUID(uuid) + file, err := q.FindAlbumThumbByUUID(uuid) if err != nil { log.Debugf("album has no photos yet, using generic thumb image: %s", uuid) diff --git a/internal/api/download.go b/internal/api/download.go index 4f892be9e..b9e452282 100644 --- a/internal/api/download.go +++ b/internal/api/download.go @@ -5,7 +5,7 @@ import ( "path" "github.com/photoprism/photoprism/internal/config" - "github.com/photoprism/photoprism/internal/repo" + "github.com/photoprism/photoprism/internal/query" "github.com/photoprism/photoprism/internal/util" "github.com/gin-gonic/gin" @@ -23,8 +23,8 @@ func GetDownload(router *gin.RouterGroup, conf *config.Config) { router.GET("/download/:hash", func(c *gin.Context) { fileHash := c.Param("hash") - r := repo.New(conf.OriginalsPath(), conf.Db()) - file, err := r.FindFileByHash(fileHash) + q := query.New(conf.OriginalsPath(), conf.Db()) + file, err := q.FindFileByHash(fileHash) if err != nil { c.AbortWithStatusJSON(404, gin.H{"error": err.Error()}) diff --git a/internal/api/label.go b/internal/api/label.go index fec3b2a1e..1b2ea8d7d 100644 --- a/internal/api/label.go +++ b/internal/api/label.go @@ -14,7 +14,7 @@ import ( "github.com/photoprism/photoprism/internal/event" "github.com/photoprism/photoprism/internal/form" "github.com/photoprism/photoprism/internal/photoprism" - "github.com/photoprism/photoprism/internal/repo" + "github.com/photoprism/photoprism/internal/query" "github.com/photoprism/photoprism/internal/util" ) @@ -23,7 +23,7 @@ func GetLabels(router *gin.RouterGroup, conf *config.Config) { router.GET("/labels", func(c *gin.Context) { var f form.LabelSearch - r := repo.New(conf.OriginalsPath(), conf.Db()) + q := query.New(conf.OriginalsPath(), conf.Db()) err := c.MustBindWith(&f, binding.Form) if err != nil { @@ -31,7 +31,7 @@ func GetLabels(router *gin.RouterGroup, conf *config.Config) { return } - result, err := r.Labels(f) + result, err := q.Labels(f) if err != nil { c.AbortWithStatusJSON(400, gin.H{"error": util.UcFirst(err.Error())}) return @@ -55,9 +55,9 @@ func LikeLabel(router *gin.RouterGroup, conf *config.Config) { return } - r := repo.New(conf.OriginalsPath(), conf.Db()) + q := query.New(conf.OriginalsPath(), conf.Db()) - label, err := r.FindLabelByUUID(c.Param("uuid")) + label, err := q.FindLabelByUUID(c.Param("uuid")) if err != nil { c.AbortWithStatusJSON(404, gin.H{"error": util.UcFirst(err.Error())}) @@ -88,9 +88,9 @@ func DislikeLabel(router *gin.RouterGroup, conf *config.Config) { return } - r := repo.New(conf.OriginalsPath(), conf.Db()) + q := query.New(conf.OriginalsPath(), conf.Db()) - label, err := r.FindLabelByUUID(c.Param("uuid")) + label, err := q.FindLabelByUUID(c.Param("uuid")) if err != nil { c.AbortWithStatusJSON(404, gin.H{"error": util.UcFirst(err.Error())}) @@ -131,7 +131,7 @@ func LabelThumbnail(router *gin.RouterGroup, conf *config.Config) { return } - r := repo.New(conf.OriginalsPath(), conf.Db()) + q := query.New(conf.OriginalsPath(), conf.Db()) gc := conf.Cache() cacheKey := fmt.Sprintf("label-thumbnail:%s:%s", labelUUID, typeName) @@ -142,7 +142,7 @@ func LabelThumbnail(router *gin.RouterGroup, conf *config.Config) { return } - file, err := r.FindLabelThumbByUUID(labelUUID) + file, err := q.FindLabelThumbByUUID(labelUUID) if err != nil { log.Errorf(err.Error()) diff --git a/internal/api/photo.go b/internal/api/photo.go index 0a5e92f1c..83fa7a819 100644 --- a/internal/api/photo.go +++ b/internal/api/photo.go @@ -7,7 +7,7 @@ import ( "github.com/photoprism/photoprism/internal/config" "github.com/photoprism/photoprism/internal/event" - "github.com/photoprism/photoprism/internal/repo" + "github.com/photoprism/photoprism/internal/query" "github.com/photoprism/photoprism/internal/util" "github.com/gin-gonic/gin" @@ -24,8 +24,8 @@ func GetPhoto(router *gin.RouterGroup, conf *config.Config) { return } - r := repo.New(conf.OriginalsPath(), conf.Db()) - p, err := r.PreloadPhotoByUUID(c.Param("uuid")) + q := query.New(conf.OriginalsPath(), conf.Db()) + p, err := q.PreloadPhotoByUUID(c.Param("uuid")) if err != nil { c.AbortWithStatusJSON(404, gin.H{"error": err.Error()}) @@ -44,9 +44,9 @@ func UpdatePhoto(router *gin.RouterGroup, conf *config.Config) { return } - r := repo.New(conf.OriginalsPath(), conf.Db()) + q := query.New(conf.OriginalsPath(), conf.Db()) - m, err := r.FindPhotoByUUID(c.Param("uuid")) + m, err := q.FindPhotoByUUID(c.Param("uuid")) if err != nil { c.AbortWithStatusJSON(404, gin.H{"error": util.UcFirst(err.Error())}) @@ -72,8 +72,8 @@ func UpdatePhoto(router *gin.RouterGroup, conf *config.Config) { // uuid: string PhotoUUID as returned by the API func GetPhotoDownload(router *gin.RouterGroup, conf *config.Config) { router.GET("/photos/:uuid/download", func(c *gin.Context) { - r := repo.New(conf.OriginalsPath(), conf.Db()) - file, err := r.FindFileByPhotoUUID(c.Param("uuid")) + q := query.New(conf.OriginalsPath(), conf.Db()) + file, err := q.FindFileByPhotoUUID(c.Param("uuid")) if err != nil { c.AbortWithStatusJSON(404, gin.H{"error": err.Error()}) @@ -111,8 +111,8 @@ func LikePhoto(router *gin.RouterGroup, conf *config.Config) { return } - r := repo.New(conf.OriginalsPath(), conf.Db()) - m, err := r.FindPhotoByUUID(c.Param("uuid")) + q := query.New(conf.OriginalsPath(), conf.Db()) + m, err := q.FindPhotoByUUID(c.Param("uuid")) if err != nil { c.AbortWithStatusJSON(404, gin.H{"error": util.UcFirst(err.Error())}) @@ -141,8 +141,8 @@ func DislikePhoto(router *gin.RouterGroup, conf *config.Config) { return } - r := repo.New(conf.OriginalsPath(), conf.Db()) - m, err := r.FindPhotoByUUID(c.Param("uuid")) + q := query.New(conf.OriginalsPath(), conf.Db()) + m, err := q.FindPhotoByUUID(c.Param("uuid")) if err != nil { c.AbortWithStatusJSON(404, gin.H{"error": util.UcFirst(err.Error())}) diff --git a/internal/api/photo_search.go b/internal/api/photo_search.go index 8cd2ea073..3be2f3a9f 100644 --- a/internal/api/photo_search.go +++ b/internal/api/photo_search.go @@ -5,7 +5,7 @@ import ( "strconv" "github.com/photoprism/photoprism/internal/config" - "github.com/photoprism/photoprism/internal/repo" + "github.com/photoprism/photoprism/internal/query" "github.com/photoprism/photoprism/internal/util" "github.com/gin-gonic/gin" @@ -31,7 +31,7 @@ func GetPhotos(router *gin.RouterGroup, conf *config.Config) { router.GET("/photos", func(c *gin.Context) { var f form.PhotoSearch - r := repo.New(conf.OriginalsPath(), conf.Db()) + q := query.New(conf.OriginalsPath(), conf.Db()) err := c.MustBindWith(&f, binding.Form) if err != nil { @@ -39,7 +39,7 @@ func GetPhotos(router *gin.RouterGroup, conf *config.Config) { return } - result, err := r.Photos(f) + result, err := q.Photos(f) if err != nil { c.AbortWithStatusJSON(400, gin.H{"error": util.UcFirst(err.Error())}) diff --git a/internal/api/photo_thumbnail.go b/internal/api/photo_thumbnail.go index 35d5c1903..a8927b9c5 100644 --- a/internal/api/photo_thumbnail.go +++ b/internal/api/photo_thumbnail.go @@ -6,7 +6,7 @@ import ( "path" "github.com/photoprism/photoprism/internal/config" - "github.com/photoprism/photoprism/internal/repo" + "github.com/photoprism/photoprism/internal/query" "github.com/photoprism/photoprism/internal/util" "github.com/gin-gonic/gin" @@ -31,8 +31,8 @@ func GetThumbnail(router *gin.RouterGroup, conf *config.Config) { return } - r := repo.New(conf.OriginalsPath(), conf.Db()) - file, err := r.FindFileByHash(fileHash) + q := query.New(conf.OriginalsPath(), conf.Db()) + file, err := q.FindFileByHash(fileHash) if err != nil { c.AbortWithStatusJSON(http.StatusNotFound, gin.H{"error": err.Error()}) diff --git a/internal/api/preview.go b/internal/api/preview.go index 66a54f5f1..edf069871 100644 --- a/internal/api/preview.go +++ b/internal/api/preview.go @@ -14,7 +14,7 @@ import ( "github.com/photoprism/photoprism/internal/config" "github.com/photoprism/photoprism/internal/form" "github.com/photoprism/photoprism/internal/photoprism" - "github.com/photoprism/photoprism/internal/repo" + "github.com/photoprism/photoprism/internal/query" "github.com/photoprism/photoprism/internal/util" ) @@ -45,8 +45,8 @@ func GetPreview(router *gin.RouterGroup, conf *config.Config) { f.Count = 12 f.Order = "relevance" - r := repo.New(conf.OriginalsPath(), conf.Db()) - p, err := r.Photos(f) + q := query.New(conf.OriginalsPath(), conf.Db()) + p, err := q.Photos(f) if err != nil { log.Error(err) diff --git a/internal/api/zip.go b/internal/api/zip.go index 18cb095ff..8c702cf45 100644 --- a/internal/api/zip.go +++ b/internal/api/zip.go @@ -12,7 +12,7 @@ import ( "github.com/photoprism/photoprism/internal/config" "github.com/photoprism/photoprism/internal/form" - "github.com/photoprism/photoprism/internal/repo" + "github.com/photoprism/photoprism/internal/query" "github.com/photoprism/photoprism/internal/util" "github.com/gin-gonic/gin" @@ -35,8 +35,8 @@ func CreateZip(router *gin.RouterGroup, conf *config.Config) { return } - r := repo.New(conf.OriginalsPath(), conf.Db()) - files, err := r.FindFilesByUUID(f.Photos, 1000, 0) + q := query.New(conf.OriginalsPath(), conf.Db()) + files, err := q.FindFilesByUUID(f.Photos, 1000, 0) if err != nil { c.AbortWithStatusJSON(404, gin.H{"error": err.Error()}) diff --git a/internal/repo/album.go b/internal/query/album.go similarity index 99% rename from internal/repo/album.go rename to internal/query/album.go index ff4ce470a..cf1b5a058 100644 --- a/internal/repo/album.go +++ b/internal/query/album.go @@ -1,4 +1,4 @@ -package repo +package query import ( "fmt" diff --git a/internal/repo/category.go b/internal/query/category.go similarity index 97% rename from internal/repo/category.go rename to internal/query/category.go index 087d5741d..7c9ce51e9 100644 --- a/internal/repo/category.go +++ b/internal/query/category.go @@ -1,4 +1,4 @@ -package repo +package query import ( "strings" diff --git a/internal/repo/category_test.go b/internal/query/category_test.go similarity index 95% rename from internal/repo/category_test.go rename to internal/query/category_test.go index ade010231..a96507a7a 100644 --- a/internal/repo/category_test.go +++ b/internal/query/category_test.go @@ -1,4 +1,4 @@ -package repo +package query import ( "testing" diff --git a/internal/repo/file.go b/internal/query/file.go similarity index 99% rename from internal/repo/file.go rename to internal/query/file.go index f9e48475b..a6a9e10e7 100644 --- a/internal/repo/file.go +++ b/internal/query/file.go @@ -1,4 +1,4 @@ -package repo +package query import "github.com/photoprism/photoprism/internal/entity" diff --git a/internal/repo/label.go b/internal/query/label.go similarity index 99% rename from internal/repo/label.go rename to internal/query/label.go index 84c85fcbc..b3e0daaad 100644 --- a/internal/repo/label.go +++ b/internal/query/label.go @@ -1,4 +1,4 @@ -package repo +package query import ( "fmt" diff --git a/internal/repo/photo.go b/internal/query/photo.go similarity index 99% rename from internal/repo/photo.go rename to internal/query/photo.go index 04aea9043..b105d9c5f 100644 --- a/internal/repo/photo.go +++ b/internal/query/photo.go @@ -1,4 +1,4 @@ -package repo +package query import ( "fmt" diff --git a/internal/repo/photo_test.go b/internal/query/photo_test.go similarity index 99% rename from internal/repo/photo_test.go rename to internal/query/photo_test.go index aa8aa157c..38f071597 100644 --- a/internal/repo/photo_test.go +++ b/internal/query/photo_test.go @@ -1,4 +1,4 @@ -package repo +package query import ( "testing" diff --git a/internal/repo/repo.go b/internal/query/repo.go similarity index 98% rename from internal/repo/repo.go rename to internal/query/repo.go index d06da6878..d99659a91 100644 --- a/internal/repo/repo.go +++ b/internal/query/repo.go @@ -5,7 +5,7 @@ Additional information can be found in our Developer Guide: https://github.com/photoprism/photoprism/wiki */ -package repo +package query import ( "github.com/photoprism/photoprism/internal/event" diff --git a/internal/repo/repo_test.go b/internal/query/repo_test.go similarity index 93% rename from internal/repo/repo_test.go rename to internal/query/repo_test.go index 8697dafb4..201bfb314 100644 --- a/internal/repo/repo_test.go +++ b/internal/query/repo_test.go @@ -1,4 +1,4 @@ -package repo +package query import ( "os"