Add studio performer count (#3362)

* Add studio performer count

* Add mocks
This commit is contained in:
DingDongSoLong4
2023-01-29 02:12:47 +02:00
committed by GitHub
parent c52d8c9314
commit 32e8496314
11 changed files with 132 additions and 5 deletions

View File

@@ -9,6 +9,7 @@ import (
"github.com/stashapp/stash/pkg/gallery"
"github.com/stashapp/stash/pkg/image"
"github.com/stashapp/stash/pkg/models"
"github.com/stashapp/stash/pkg/performer"
)
func (r *studioResolver) Name(ctx context.Context, obj *models.Studio) (string, error) {
@@ -93,6 +94,18 @@ func (r *studioResolver) GalleryCount(ctx context.Context, obj *models.Studio) (
return &res, nil
}
func (r *studioResolver) PerformerCount(ctx context.Context, obj *models.Studio) (ret *int, err error) {
var res int
if err := r.withReadTxn(ctx, func(ctx context.Context) error {
res, err = performer.CountByStudioID(ctx, r.repository.Performer, obj.ID)
return err
}); err != nil {
return nil, err
}
return &res, nil
}
func (r *studioResolver) ParentStudio(ctx context.Context, obj *models.Studio) (ret *models.Studio, err error) {
if !obj.ParentID.Valid {
return nil, nil