From 43abf0bd8321eac09ea3049bcc87085fd0986480 Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Wed, 24 Jun 2020 08:34:23 +0200 Subject: [PATCH] Photos: Rename maintained_at to checked_at Signed-off-by: Michael Mayer --- frontend/src/dialog/photo/info.vue | 6 +++--- frontend/src/model/photo.js | 4 ++-- internal/entity/photo.go | 2 +- internal/entity/photo_maintain.go | 4 ++-- internal/query/photo.go | 6 +++--- internal/query/photo_results.go | 2 ++ internal/workers/prism.go | 10 +++++----- 7 files changed, 18 insertions(+), 16 deletions(-) diff --git a/frontend/src/dialog/photo/info.vue b/frontend/src/dialog/photo/info.vue index 5032dfb12..60bbfd24a 100644 --- a/frontend/src/dialog/photo/info.vue +++ b/frontend/src/dialog/photo/info.vue @@ -122,10 +122,10 @@ {{ model.EditedAt | luxon:format('http') }} - - Maintained + + Checked - {{ model.MaintainedAt | luxon:format('http') }} + {{ model.CheckedAt | luxon:format('http') }} diff --git a/frontend/src/model/photo.js b/frontend/src/model/photo.js index 62b222171..74ca6b643 100644 --- a/frontend/src/model/photo.js +++ b/frontend/src/model/photo.js @@ -115,9 +115,9 @@ export class Photo extends RestModel { // Date fields. CreatedAt: "", UpdatedAt: "", - DeletedAt: null, EditedAt: null, - MaintainedAt: null, + CheckedAt: null, + DeletedAt: null, }; } diff --git a/internal/entity/photo.go b/internal/entity/photo.go index 20e6c3d63..6493bb945 100644 --- a/internal/entity/photo.go +++ b/internal/entity/photo.go @@ -82,7 +82,7 @@ type Photo struct { CreatedAt time.Time `yaml:"CreatedAt,omitempty"` UpdatedAt time.Time `yaml:"UpdatedAt,omitempty"` EditedAt *time.Time `yaml:"EditedAt,omitempty"` - MaintainedAt *time.Time `sql:"index" yaml:"-"` + CheckedAt *time.Time `sql:"index" yaml:"-"` DeletedAt *time.Time `sql:"index" yaml:"DeletedAt,omitempty"` } diff --git a/internal/entity/photo_maintain.go b/internal/entity/photo_maintain.go index a8e96d527..26a327a05 100644 --- a/internal/entity/photo_maintain.go +++ b/internal/entity/photo_maintain.go @@ -98,8 +98,8 @@ func (m *Photo) Maintain() error { return errors.New("photo: can't maintain, id is empty") } - maintained := time.Now() - m.MaintainedAt = &maintained + checked := time.Now() + m.CheckedAt = &checked m.EstimatePlace() diff --git a/internal/query/photo.go b/internal/query/photo.go index d72399a91..4d778c4b6 100644 --- a/internal/query/photo.go +++ b/internal/query/photo.go @@ -90,8 +90,8 @@ func ResetPhotoQuality() error { Update("photo_quality", -1).Error } -// PhotosMaintenance returns photos selected for maintenance. -func PhotosMaintenance(limit int, offset int) (entities entity.Photos, err error) { +// PhotosCheck returns photos selected for maintenance. +func PhotosCheck(limit int, offset int) (entities entity.Photos, err error) { err = Db(). Preload("Labels", func(db *gorm.DB) *gorm.DB { return db.Order("photos_labels.uncertainty ASC, photos_labels.label_id DESC") @@ -103,7 +103,7 @@ func PhotosMaintenance(limit int, offset int) (entities entity.Photos, err error Preload("Place"). Preload("Location"). Preload("Location.Place"). - Where("maintained_at IS NULL OR maintained_at < ?", time.Now().Add(-1*time.Hour*24*3)). + Where("checked_at IS NULL OR checked_at < ?", time.Now().Add(-1*time.Hour*24*3)). Where("updated_at < ?", time.Now().Add(-1*time.Minute*10)). Limit(limit).Offset(offset).Find(&entities).Error diff --git a/internal/query/photo_results.go b/internal/query/photo_results.go index f8881e146..0dc2d3527 100644 --- a/internal/query/photo_results.go +++ b/internal/query/photo_results.go @@ -81,6 +81,8 @@ type PhotoResult struct { Merged bool `json:"Merged"` CreatedAt time.Time `json:"CreatedAt"` UpdatedAt time.Time `json:"UpdatedAt"` + EditedAt time.Time `json:"EditedAt,omitempty"` + CheckedAt time.Time `json:"CheckedAt,omitempty"` DeletedAt time.Time `json:"DeletedAt,omitempty"` Files []entity.File `json:"Files"` diff --git a/internal/workers/prism.go b/internal/workers/prism.go index 5b1a9a489..6c8823ca7 100644 --- a/internal/workers/prism.go +++ b/internal/workers/prism.go @@ -62,7 +62,7 @@ func (worker *Prism) Start() (err error) { offset := 0 for { - photos, err := query.PhotosMaintenance(limit, offset) + photos, err := query.PhotosCheck(limit, offset) if err != nil { return err @@ -71,12 +71,12 @@ func (worker *Prism) Start() (err error) { if len(photos) == 0 { break } else if offset == 0 { - log.Infof("prism: starting metadata optimization") + log.Infof("prism: starting routine check") } for _, photo := range photos { if mutex.PrismWorker.Canceled() { - return errors.New("prism: optimization canceled") + return errors.New("prism: check canceled") } if done[photo.PhotoUID] { @@ -89,7 +89,7 @@ func (worker *Prism) Start() (err error) { } if mutex.PrismWorker.Canceled() { - return errors.New("prism: optimization canceled") + return errors.New("prism: check canceled") } offset += limit @@ -98,7 +98,7 @@ func (worker *Prism) Start() (err error) { } if len(done) > 0 { - log.Infof("prism: optimized %d photos", len(done)) + log.Infof("prism: checked %d photos", len(done)) } worker.logError(query.ResetPhotoQuality())