mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
Feature: Tag StashID support (#6255)
This commit is contained in:
@@ -54,6 +54,16 @@ func (r *tagResolver) Aliases(ctx context.Context, obj *models.Tag) (ret []strin
|
||||
return obj.Aliases.List(), nil
|
||||
}
|
||||
|
||||
func (r *tagResolver) StashIds(ctx context.Context, obj *models.Tag) ([]*models.StashID, error) {
|
||||
if err := r.withReadTxn(ctx, func(ctx context.Context) error {
|
||||
return obj.LoadStashIDs(ctx, r.repository.Tag)
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return stashIDsSliceToPtrSlice(obj.StashIDs.List()), nil
|
||||
}
|
||||
|
||||
func (r *tagResolver) SceneCount(ctx context.Context, obj *models.Tag, depth *int) (ret int, err error) {
|
||||
if err := r.withReadTxn(ctx, func(ctx context.Context) error {
|
||||
ret, err = scene.CountByTagID(ctx, r.repository.Scene, obj.ID, depth)
|
||||
|
||||
@@ -153,6 +153,14 @@ func (r *mutationResolver) makeSceneDraft(ctx context.Context, s *models.Scene,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Load StashIDs for tags
|
||||
tqb := r.repository.Tag
|
||||
for _, t := range draft.Tags {
|
||||
if err := t.LoadStashIDs(ctx, tqb); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
draft.Cover = cover
|
||||
|
||||
return draft, nil
|
||||
|
||||
@@ -39,6 +39,14 @@ func (r *mutationResolver) TagCreate(ctx context.Context, input TagCreateInput)
|
||||
newTag.Description = translator.string(input.Description)
|
||||
newTag.IgnoreAutoTag = translator.bool(input.IgnoreAutoTag)
|
||||
|
||||
var stashIDInputs models.StashIDInputs
|
||||
for _, sid := range input.StashIds {
|
||||
if sid != nil {
|
||||
stashIDInputs = append(stashIDInputs, *sid)
|
||||
}
|
||||
}
|
||||
newTag.StashIDs = models.NewRelatedStashIDs(stashIDInputs.ToStashIDs())
|
||||
|
||||
var err error
|
||||
|
||||
newTag.ParentIDs, err = translator.relatedIds(input.ParentIds)
|
||||
@@ -110,6 +118,14 @@ func (r *mutationResolver) TagUpdate(ctx context.Context, input TagUpdateInput)
|
||||
|
||||
updatedTag.Aliases = translator.updateStrings(input.Aliases, "aliases")
|
||||
|
||||
var updateStashIDInputs models.StashIDInputs
|
||||
for _, sid := range input.StashIds {
|
||||
if sid != nil {
|
||||
updateStashIDInputs = append(updateStashIDInputs, *sid)
|
||||
}
|
||||
}
|
||||
updatedTag.StashIDs = translator.updateStashIDs(updateStashIDInputs, "stash_ids")
|
||||
|
||||
updatedTag.ParentIDs, err = translator.updateIds(input.ParentIds, "parent_ids")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("converting parent tag ids: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user