Files
stash/pkg/image/query.go
WithoutPants ea54a67798 Add scene/image/gallery popover count buttons for performer/studio/tag cards (#1293)
* Add counts to graphql schema
* Add count resolvers and query refactor
* Add count popover buttons
2021-04-15 10:46:31 +10:00

41 lines
906 B
Go

package image
import (
"strconv"
"github.com/stashapp/stash/pkg/models"
)
func CountByPerformerID(r models.ImageReader, id int) (int, error) {
filter := &models.ImageFilterType{
Performers: &models.MultiCriterionInput{
Value: []string{strconv.Itoa(id)},
Modifier: models.CriterionModifierIncludes,
},
}
return r.QueryCount(filter, nil)
}
func CountByStudioID(r models.ImageReader, id int) (int, error) {
filter := &models.ImageFilterType{
Studios: &models.MultiCriterionInput{
Value: []string{strconv.Itoa(id)},
Modifier: models.CriterionModifierIncludes,
},
}
return r.QueryCount(filter, nil)
}
func CountByTagID(r models.ImageReader, id int) (int, error) {
filter := &models.ImageFilterType{
Tags: &models.MultiCriterionInput{
Value: []string{strconv.Itoa(id)},
Modifier: models.CriterionModifierIncludes,
},
}
return r.QueryCount(filter, nil)
}