mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 20:34:37 +03:00
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:
@@ -9,6 +9,8 @@ import (
|
||||
"github.com/stashapp/stash/pkg/database"
|
||||
)
|
||||
|
||||
const galleryTable = "galleries"
|
||||
|
||||
type GalleryQueryBuilder struct{}
|
||||
|
||||
func NewGalleryQueryBuilder() GalleryQueryBuilder {
|
||||
@@ -112,25 +114,36 @@ func (qb *GalleryQueryBuilder) All() ([]*Gallery, error) {
|
||||
return qb.queryGalleries(selectAll("galleries")+qb.getGallerySort(nil), nil, nil)
|
||||
}
|
||||
|
||||
func (qb *GalleryQueryBuilder) Query(findFilter *FindFilterType) ([]*Gallery, int) {
|
||||
func (qb *GalleryQueryBuilder) Query(galleryFilter *GalleryFilterType, findFilter *FindFilterType) ([]*Gallery, int) {
|
||||
if galleryFilter == nil {
|
||||
galleryFilter = &GalleryFilterType{}
|
||||
}
|
||||
if findFilter == nil {
|
||||
findFilter = &FindFilterType{}
|
||||
}
|
||||
|
||||
var whereClauses []string
|
||||
var havingClauses []string
|
||||
var args []interface{}
|
||||
body := selectDistinctIDs("galleries")
|
||||
query := queryBuilder{
|
||||
tableName: galleryTable,
|
||||
}
|
||||
|
||||
query.body = selectDistinctIDs("galleries")
|
||||
|
||||
if q := findFilter.Q; q != nil && *q != "" {
|
||||
searchColumns := []string{"galleries.path", "galleries.checksum"}
|
||||
clause, thisArgs := getSearchBinding(searchColumns, *q, false)
|
||||
whereClauses = append(whereClauses, clause)
|
||||
args = append(args, thisArgs...)
|
||||
query.addWhere(clause)
|
||||
query.addArg(thisArgs...)
|
||||
}
|
||||
|
||||
sortAndPagination := qb.getGallerySort(findFilter) + getPagination(findFilter)
|
||||
idsResult, countResult := executeFindQuery("galleries", body, args, sortAndPagination, whereClauses, havingClauses)
|
||||
if isMissingFilter := galleryFilter.IsMissing; isMissingFilter != nil && *isMissingFilter != "" {
|
||||
switch *isMissingFilter {
|
||||
case "scene":
|
||||
query.addWhere("galleries.scene_id IS NULL")
|
||||
}
|
||||
}
|
||||
|
||||
query.sortAndPagination = qb.getGallerySort(findFilter) + getPagination(findFilter)
|
||||
idsResult, countResult := query.executeFind()
|
||||
|
||||
var galleries []*Gallery
|
||||
for _, id := range idsResult {
|
||||
|
||||
Reference in New Issue
Block a user