Add movie count to performer and studio card (#1760)

* Add movies and movie_count properties to Performer type

Extend the GraphQL API to allow getting the movies and movie count by
performer.

* Add movies count to performer card

* Add movies and movie_count properties to Studio type

Extend the GraphQL API to allow getting the movies and movie count by
studio.

* Add movies count to studio card
This commit is contained in:
gitgiggety
2021-09-27 03:31:49 +02:00
committed by GitHub
parent 62af723017
commit be94e52f21
15 changed files with 257 additions and 3 deletions

View File

@@ -151,3 +151,26 @@ func (r *studioResolver) CreatedAt(ctx context.Context, obj *models.Studio) (*ti
func (r *studioResolver) UpdatedAt(ctx context.Context, obj *models.Studio) (*time.Time, error) {
return &obj.UpdatedAt.Timestamp, nil
}
func (r *studioResolver) Movies(ctx context.Context, obj *models.Studio) (ret []*models.Movie, err error) {
if err := r.withReadTxn(ctx, func(repo models.ReaderRepository) error {
ret, err = repo.Movie().FindByStudioID(obj.ID)
return err
}); err != nil {
return nil, err
}
return ret, nil
}
func (r *studioResolver) MovieCount(ctx context.Context, obj *models.Studio) (ret *int, err error) {
var res int
if err := r.withReadTxn(ctx, func(repo models.ReaderRepository) error {
res, err = repo.Movie().CountByStudioID(obj.ID)
return err
}); err != nil {
return nil, err
}
return &res, nil
}