Files
stash/pkg/performer/query.go
DingDongSoLong4 f65e87773c Include subsidiary studios/tags in tab badge counters (#3816)
* Add '_all' counts
* Use '_all' counts in UI
* Make other counts non-nullable
* Hide tab counts if zero
* Add resolver parameter
2023-06-16 10:46:14 +10:00

52 lines
1.4 KiB
Go

package performer
import (
"context"
"strconv"
"github.com/stashapp/stash/pkg/models"
)
type Queryer interface {
Query(ctx context.Context, performerFilter *models.PerformerFilterType, findFilter *models.FindFilterType) ([]*models.Performer, int, error)
}
type CountQueryer interface {
QueryCount(ctx context.Context, galleryFilter *models.PerformerFilterType, findFilter *models.FindFilterType) (int, error)
}
func CountByStudioID(ctx context.Context, r CountQueryer, id int, depth *int) (int, error) {
filter := &models.PerformerFilterType{
Studios: &models.HierarchicalMultiCriterionInput{
Value: []string{strconv.Itoa(id)},
Modifier: models.CriterionModifierIncludes,
Depth: depth,
},
}
return r.QueryCount(ctx, filter, nil)
}
func CountByTagID(ctx context.Context, r CountQueryer, id int, depth *int) (int, error) {
filter := &models.PerformerFilterType{
Tags: &models.HierarchicalMultiCriterionInput{
Value: []string{strconv.Itoa(id)},
Modifier: models.CriterionModifierIncludes,
Depth: depth,
},
}
return r.QueryCount(ctx, filter, nil)
}
func CountByAppearsWith(ctx context.Context, r CountQueryer, id int) (int, error) {
filter := &models.PerformerFilterType{
Performers: &models.MultiCriterionInput{
Value: []string{strconv.Itoa(id)},
Modifier: models.CriterionModifierIncludes,
},
}
return r.QueryCount(ctx, filter, nil)
}