mirror of
https://github.com/photoprism/photoprism.git
synced 2025-12-12 00:34:13 +01:00
Backend: Rename repo package to query
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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()})
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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())})
|
||||
|
||||
@@ -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())})
|
||||
|
||||
@@ -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()})
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()})
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package repo
|
||||
package query
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -1,4 +1,4 @@
|
||||
package repo
|
||||
package query
|
||||
|
||||
import (
|
||||
"strings"
|
||||
@@ -1,4 +1,4 @@
|
||||
package repo
|
||||
package query
|
||||
|
||||
import (
|
||||
"testing"
|
||||
@@ -1,4 +1,4 @@
|
||||
package repo
|
||||
package query
|
||||
|
||||
import "github.com/photoprism/photoprism/internal/entity"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package repo
|
||||
package query
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -1,4 +1,4 @@
|
||||
package repo
|
||||
package query
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -1,4 +1,4 @@
|
||||
package repo
|
||||
package query
|
||||
|
||||
import (
|
||||
"testing"
|
||||
@@ -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"
|
||||
@@ -1,4 +1,4 @@
|
||||
package repo
|
||||
package query
|
||||
|
||||
import (
|
||||
"os"
|
||||
Reference in New Issue
Block a user