Fix places count while indexing

Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
Michael Mayer 2020-06-09 10:49:27 +02:00
parent d72480200e
commit aedc0279e3
3 changed files with 3 additions and 2 deletions

View file

@ -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 {

View file

@ -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:"-"`

View file

@ -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 != "" {