Purge: Improve tests and logs for RegenerateIndex() #2540
Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
parent
f1b717fbfd
commit
f14752f08c
2 changed files with 16 additions and 4 deletions
|
@ -115,16 +115,16 @@ func (m File) RegenerateIndex() {
|
|||
|
||||
if m.PhotoID > 0 {
|
||||
updateWhere = gorm.Expr("files.photo_id = ?", m.PhotoID)
|
||||
scope = "partial file index"
|
||||
scope = "index by photo id"
|
||||
} else if m.PhotoUID != "" {
|
||||
updateWhere = gorm.Expr("files.photo_uid = ?", m.PhotoUID)
|
||||
scope = "partial file index"
|
||||
scope = "index by photo uid"
|
||||
} else if m.ID > 0 {
|
||||
updateWhere = gorm.Expr("files.id = ?", m.ID)
|
||||
scope = "partial file index"
|
||||
scope = "index by file id"
|
||||
} else {
|
||||
updateWhere = gorm.Expr("files.photo_id IS NOT NULL")
|
||||
scope = "file index"
|
||||
scope = "index"
|
||||
}
|
||||
|
||||
switch DbDialect() {
|
||||
|
|
|
@ -14,6 +14,15 @@ import (
|
|||
)
|
||||
|
||||
func TestFile_RegenerateIndex(t *testing.T) {
|
||||
t.Run("ID", func(t *testing.T) {
|
||||
File{ID: 1000000}.RegenerateIndex()
|
||||
})
|
||||
t.Run("PhotoID", func(t *testing.T) {
|
||||
File{PhotoID: 1000039}.RegenerateIndex()
|
||||
})
|
||||
t.Run("PhotoUID", func(t *testing.T) {
|
||||
File{PhotoUID: "pr2xu7myk7wrbk32"}.RegenerateIndex()
|
||||
})
|
||||
t.Run("FirstFileByHash", func(t *testing.T) {
|
||||
f, err := FirstFileByHash("2cad9168fa6acc5c5c2965ddf6ec465ca42fd818")
|
||||
if err != nil {
|
||||
|
@ -21,6 +30,9 @@ func TestFile_RegenerateIndex(t *testing.T) {
|
|||
}
|
||||
f.RegenerateIndex()
|
||||
})
|
||||
t.Run("All", func(t *testing.T) {
|
||||
File{}.RegenerateIndex()
|
||||
})
|
||||
}
|
||||
|
||||
func TestFirstFileByHash(t *testing.T) {
|
||||
|
|
Loading…
Reference in a new issue