2021-08-12 04:54:20 +02:00
|
|
|
package query
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/photoprism/photoprism/internal/entity"
|
|
|
|
)
|
|
|
|
|
|
|
|
// People finds a list of people.
|
|
|
|
func People(limit, offset int, embeddings bool) (result entity.People, err error) {
|
|
|
|
stmt := Db()
|
|
|
|
|
|
|
|
if embeddings {
|
|
|
|
stmt = stmt.Where("embeddings <> ''")
|
|
|
|
}
|
|
|
|
|
|
|
|
stmt = stmt.Order("id").Limit(limit).Offset(offset)
|
|
|
|
err = stmt.Find(&result).Error
|
|
|
|
|
|
|
|
return result, err
|
|
|
|
}
|
|
|
|
|
2021-08-13 20:31:41 +02:00
|
|
|
// Faces finds a list of faces.
|
|
|
|
func Faces() (result entity.Faces, err error) {
|
2021-08-12 04:54:20 +02:00
|
|
|
stmt := Db().
|
|
|
|
Order("id")
|
|
|
|
|
|
|
|
err = stmt.Find(&result).Error
|
|
|
|
|
|
|
|
return result, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// PurgeUnknownFaces removes unknown faces from the index.
|
|
|
|
func PurgeUnknownFaces() error {
|
|
|
|
return UnscopedDb().Delete(
|
2021-08-13 20:31:41 +02:00
|
|
|
entity.Face{},
|
2021-08-12 12:05:10 +02:00
|
|
|
"person_uid = '' AND updated_at < ?", entity.Yesterday()).Error
|
2021-08-12 04:54:20 +02:00
|
|
|
}
|