mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 12:54:38 +03:00
Studio Tagger (#3510)
* Studio image and parent studio support in scene tagger * Refactor studio backend and add studio tagger --------- Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"io"
|
||||
"strconv"
|
||||
|
||||
"github.com/stashapp/stash/pkg/sliceutil"
|
||||
"github.com/stashapp/stash/pkg/sliceutil/intslice"
|
||||
)
|
||||
|
||||
@@ -94,16 +95,7 @@ func (u *UpdateIDs) EffectiveIDs(existing []int) []int {
|
||||
return nil
|
||||
}
|
||||
|
||||
switch u.Mode {
|
||||
case RelationshipUpdateModeAdd:
|
||||
return intslice.IntAppendUniques(existing, u.IDs)
|
||||
case RelationshipUpdateModeRemove:
|
||||
return intslice.IntExclude(existing, u.IDs)
|
||||
case RelationshipUpdateModeSet:
|
||||
return u.IDs
|
||||
}
|
||||
|
||||
return nil
|
||||
return effectiveValues(u.IDs, u.Mode, existing)
|
||||
}
|
||||
|
||||
type UpdateStrings struct {
|
||||
@@ -118,3 +110,26 @@ func (u *UpdateStrings) Strings() []string {
|
||||
|
||||
return u.Values
|
||||
}
|
||||
|
||||
// GetEffectiveIDs returns the new IDs that will be effective after the update.
|
||||
func (u *UpdateStrings) EffectiveValues(existing []string) []string {
|
||||
if u == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return effectiveValues(u.Values, u.Mode, existing)
|
||||
}
|
||||
|
||||
// effectiveValues returns the new values that will be effective after the update.
|
||||
func effectiveValues[T comparable](values []T, mode RelationshipUpdateMode, existing []T) []T {
|
||||
switch mode {
|
||||
case RelationshipUpdateModeAdd:
|
||||
return sliceutil.AppendUniques(existing, values)
|
||||
case RelationshipUpdateModeRemove:
|
||||
return sliceutil.Exclude(existing, values)
|
||||
case RelationshipUpdateModeSet:
|
||||
return values
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user