Search albums by country (#905)
This commit is contained in:
parent
67e655f6d0
commit
a90ee62cd6
3 changed files with 17 additions and 1 deletions
|
@ -66,6 +66,7 @@ var AlbumFixtures = AlbumMap{
|
|||
AlbumNotes: "",
|
||||
AlbumOrder: "oldest",
|
||||
AlbumTemplate: "",
|
||||
AlbumCountry: "de",
|
||||
AlbumFavorite: false,
|
||||
CreatedAt: time.Date(2019, 7, 1, 0, 0, 0, 0, time.UTC),
|
||||
UpdatedAt: time.Date(2020, 2, 1, 0, 0, 0, 0, time.UTC),
|
||||
|
|
|
@ -143,6 +143,10 @@ func AlbumSearch(f form.AlbumSearch) (results AlbumResults, err error) {
|
|||
s = s.Where("albums.album_location IN (?)", strings.Split(f.Location, Or))
|
||||
}
|
||||
|
||||
if f.Country != "" {
|
||||
s = s.Where("albums.album_country IN (?)", strings.Split(f.Country, Or))
|
||||
}
|
||||
|
||||
if f.Favorite {
|
||||
s = s.Where("albums.album_favorite = 1")
|
||||
}
|
||||
|
@ -199,7 +203,7 @@ func UpdateAlbumDates() error {
|
|||
func UpdateMissingAlbumEntries() error {
|
||||
switch DbDialect() {
|
||||
default:
|
||||
return UnscopedDb().Exec(`UPDATE photos_albums SET missing = 1 WHERE photo_uid IN
|
||||
return UnscopedDb().Exec(`UPDATE photos_albums SET missing = 1 WHERE photo_uid IN
|
||||
(SELECT photo_uid FROM photos WHERE deleted_at IS NOT NULL OR photo_quality < 0)`).Error
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,6 +98,17 @@ func TestAlbumSearch(t *testing.T) {
|
|||
assert.Equal(t, "Holiday2030", result[0].AlbumTitle)
|
||||
})
|
||||
|
||||
t.Run("search with country", func(t *testing.T) {
|
||||
query := form.NewAlbumSearch("country:de")
|
||||
result, err := AlbumSearch(query)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
assert.Equal(t, "Berlin 2019", result[0].AlbumTitle)
|
||||
})
|
||||
|
||||
t.Run("favorites true", func(t *testing.T) {
|
||||
query := form.NewAlbumSearch("favorite:true count:10000")
|
||||
|
||||
|
|
Loading…
Reference in a new issue