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:
Flashy78
2023-07-30 16:50:24 -07:00
committed by GitHub
parent d48dbeb864
commit a665a56ef0
79 changed files with 5224 additions and 1039 deletions

View File

@@ -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
}