mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
* Add new txn manager interface * Add txn management to sqlite * Rename get to getByID * Add contexts to repository methods * Update query builders * Add context to reader writer interfaces * Use repository in resolver * Tighten interfaces * Tighten interfaces in dlna * Tighten interfaces in match package * Tighten interfaces in scraper package * Tighten interfaces in scan code * Tighten interfaces on autotag package * Remove ReaderWriter usage * Merge database package into sqlite
54 lines
1.4 KiB
Go
54 lines
1.4 KiB
Go
package gallery
|
|
|
|
import (
|
|
"context"
|
|
"strconv"
|
|
|
|
"github.com/stashapp/stash/pkg/models"
|
|
)
|
|
|
|
type Queryer interface {
|
|
Query(ctx context.Context, galleryFilter *models.GalleryFilterType, findFilter *models.FindFilterType) ([]*models.Gallery, int, error)
|
|
}
|
|
|
|
type CountQueryer interface {
|
|
QueryCount(ctx context.Context, galleryFilter *models.GalleryFilterType, findFilter *models.FindFilterType) (int, error)
|
|
}
|
|
|
|
type ChecksumsFinder interface {
|
|
FindByChecksums(ctx context.Context, checksums []string) ([]*models.Gallery, error)
|
|
}
|
|
|
|
func CountByPerformerID(ctx context.Context, r CountQueryer, id int) (int, error) {
|
|
filter := &models.GalleryFilterType{
|
|
Performers: &models.MultiCriterionInput{
|
|
Value: []string{strconv.Itoa(id)},
|
|
Modifier: models.CriterionModifierIncludes,
|
|
},
|
|
}
|
|
|
|
return r.QueryCount(ctx, filter, nil)
|
|
}
|
|
|
|
func CountByStudioID(ctx context.Context, r CountQueryer, id int) (int, error) {
|
|
filter := &models.GalleryFilterType{
|
|
Studios: &models.HierarchicalMultiCriterionInput{
|
|
Value: []string{strconv.Itoa(id)},
|
|
Modifier: models.CriterionModifierIncludes,
|
|
},
|
|
}
|
|
|
|
return r.QueryCount(ctx, filter, nil)
|
|
}
|
|
|
|
func CountByTagID(ctx context.Context, r CountQueryer, id int) (int, error) {
|
|
filter := &models.GalleryFilterType{
|
|
Tags: &models.HierarchicalMultiCriterionInput{
|
|
Value: []string{strconv.Itoa(id)},
|
|
Modifier: models.CriterionModifierIncludes,
|
|
},
|
|
}
|
|
|
|
return r.QueryCount(ctx, filter, nil)
|
|
}
|