Files
stash/pkg/performer/query.go
dogwithakeyboard 3bc5caa6de Add performer pairings/appears with tab to performers (#3563)
* database query

* Appears With panel

* Typos

* Validation fix

* naming consistency,  remove extraneous component.

---------

Co-authored-by: kermieisinthehouse <kermie@isinthe.house>
2023-04-24 17:38:49 -04:00

39 lines
1.0 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) (int, error) {
filter := &models.PerformerFilterType{
Studios: &models.HierarchicalMultiCriterionInput{
Value: []string{strconv.Itoa(id)},
Modifier: models.CriterionModifierIncludes,
},
}
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)
}