photoprism/internal/photoprism/index_location.go
Michael Mayer 2156afd85a File browser: Implement clipboard; refactor entities and fixtures #260
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
2020-05-25 19:10:44 +02:00

20 lines
644 B
Go

package photoprism
import (
"github.com/jinzhu/gorm"
"github.com/photoprism/photoprism/internal/entity"
"github.com/photoprism/photoprism/pkg/txt"
)
func (ind *Index) estimateLocation(photo *entity.Photo) {
var recentPhoto entity.Photo
if result := ind.db.Unscoped().Order(gorm.Expr("ABS(DATEDIFF(taken_at, ?)) ASC", photo.TakenAt)).Preload("Place").First(&recentPhoto); result.Error == nil {
if recentPhoto.HasPlace() {
photo.Place = recentPhoto.Place
photo.PhotoCountry = photo.Place.LocCountry
photo.LocSrc = entity.SrcAuto
log.Debugf("index: approximate location is %s", txt.Quote(recentPhoto.Place.Label()))
}
}
}