From aedc0279e3afd3eb152d90824b34f7c35c74ab0c Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Tue, 9 Jun 2020 10:49:27 +0200 Subject: [PATCH] Fix places count while indexing Signed-off-by: Michael Mayer --- internal/entity/location.go | 1 + internal/entity/place.go | 2 +- internal/query/photo_search.go | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/entity/location.go b/internal/entity/location.go index 43df713a0..812b96486 100644 --- a/internal/entity/location.go +++ b/internal/entity/location.go @@ -75,6 +75,7 @@ func (m *Location) Find(api string) error { LocState: l.State(), LocCountry: l.CountryCode(), LocKeywords: l.KeywordString(), + PhotoCount: 1, } if err := place.Create(); err != nil { diff --git a/internal/entity/place.go b/internal/entity/place.go index 7b23c93c9..8f906895c 100644 --- a/internal/entity/place.go +++ b/internal/entity/place.go @@ -19,7 +19,7 @@ type Place struct { LocKeywords string `gorm:"type:varchar(255);" json:"Keywords" yaml:"Keywords,omitempty"` LocNotes string `gorm:"type:text;" json:"Notes" yaml:"Notes,omitempty"` LocFavorite bool `json:"Favorite" yaml:"Favorite,omitempty"` - PhotoCount int `json:"PhotoCount" yaml:"-"` + PhotoCount int `gorm:"default:1" json:"PhotoCount" yaml:"-"` CreatedAt time.Time `json:"CreatedAt" yaml:"-"` UpdatedAt time.Time `json:"UpdatedAt" yaml:"-"` New bool `gorm:"-" json:"-" yaml:"-"` diff --git a/internal/query/photo_search.go b/internal/query/photo_search.go index d33b223f8..b158d86a7 100644 --- a/internal/query/photo_search.go +++ b/internal/query/photo_search.go @@ -186,7 +186,7 @@ func PhotoSearch(f form.PhotoSearch) (results PhotoResults, count int, err error } if f.State != "" { - s = s.Where("places.loc_state IN (?)", strings.Split(txt.Title(f.State), ",")) + s = s.Where("places.loc_state IN (?)", strings.Split(f.State, ",")) } if f.Category != "" {