Gallery list improvement (#622)

* Add grid view to galleries
* Show scene in gallery card
* Add is missing scene gallery filter
* Don't store galleries with no images
This commit is contained in:
WithoutPants
2020-06-21 21:43:57 +10:00
committed by GitHub
parent e50f1d01be
commit d3ababf0a1
26 changed files with 296 additions and 35 deletions

View File

@@ -98,6 +98,58 @@ func TestGalleryFindBySceneID(t *testing.T) {
assert.Nil(t, gallery)
}
func TestGalleryQueryQ(t *testing.T) {
const galleryIdx = 0
q := getGalleryStringValue(galleryIdx, pathField)
sqb := models.NewGalleryQueryBuilder()
galleryQueryQ(t, sqb, q, galleryIdx)
}
func galleryQueryQ(t *testing.T, qb models.GalleryQueryBuilder, q string, expectedGalleryIdx int) {
filter := models.FindFilterType{
Q: &q,
}
galleries, _ := qb.Query(nil, &filter)
assert.Len(t, galleries, 1)
gallery := galleries[0]
assert.Equal(t, galleryIDs[expectedGalleryIdx], gallery.ID)
// no Q should return all results
filter.Q = nil
galleries, _ = qb.Query(nil, &filter)
assert.Len(t, galleries, totalGalleries)
}
func TestGalleryQueryIsMissingScene(t *testing.T) {
qb := models.NewGalleryQueryBuilder()
isMissing := "scene"
galleryFilter := models.GalleryFilterType{
IsMissing: &isMissing,
}
q := getGalleryStringValue(galleryIdxWithScene, titleField)
findFilter := models.FindFilterType{
Q: &q,
}
galleries, _ := qb.Query(&galleryFilter, &findFilter)
assert.Len(t, galleries, 0)
findFilter.Q = nil
galleries, _ = qb.Query(&galleryFilter, &findFilter)
// ensure non of the ids equal the one with gallery
for _, gallery := range galleries {
assert.NotEqual(t, galleryIDs[galleryIdxWithScene], gallery.ID)
}
}
// TODO ValidGalleriesForScenePath
// TODO Count
// TODO All