mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 16:34:02 +01:00
* Rename Movie and MoviePartial to Group/GroupPartial * Rename Movie interfaces * Update movie url builders to use group * Rename movieRoutes to groupRoutes * Update dataloader * Update names in sqlite package * Rename in resolvers * Add GroupByURL to scraper config * Scraper backward compatibility hacks
59 lines
1.2 KiB
Go
59 lines
1.2 KiB
Go
package api
|
|
|
|
import (
|
|
"context"
|
|
"strconv"
|
|
|
|
"github.com/stashapp/stash/pkg/models"
|
|
"github.com/stashapp/stash/pkg/sliceutil/stringslice"
|
|
)
|
|
|
|
func (r *queryResolver) FindGroup(ctx context.Context, id string) (ret *models.Group, err error) {
|
|
idInt, err := strconv.Atoi(id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if err := r.withReadTxn(ctx, func(ctx context.Context) error {
|
|
ret, err = r.repository.Group.Find(ctx, idInt)
|
|
return err
|
|
}); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func (r *queryResolver) FindGroups(ctx context.Context, groupFilter *models.GroupFilterType, filter *models.FindFilterType, ids []string) (ret *FindGroupsResultType, err error) {
|
|
idInts, err := stringslice.StringSliceToIntSlice(ids)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if err := r.withReadTxn(ctx, func(ctx context.Context) error {
|
|
var groups []*models.Group
|
|
var err error
|
|
var total int
|
|
|
|
if len(idInts) > 0 {
|
|
groups, err = r.repository.Group.FindMany(ctx, idInts)
|
|
total = len(groups)
|
|
} else {
|
|
groups, total, err = r.repository.Group.Query(ctx, groupFilter, filter)
|
|
}
|
|
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
ret = &FindGroupsResultType{
|
|
Count: total,
|
|
Groups: groups,
|
|
}
|
|
return nil
|
|
}); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return ret, nil
|
|
}
|