mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Multiple scene URLs (#3852)
* Add URLs scene relationship * Update unit tests * Update scene edit and details pages * Update scrapers to use urls * Post-process scenes during query scrape * Update UI for URLs * Change urls label
This commit is contained in:
@@ -2,6 +2,53 @@ package sliceutil
|
||||
|
||||
import "reflect"
|
||||
|
||||
// Exclude removes all instances of any value in toExclude from the vs
|
||||
// slice. It returns the new or unchanged slice.
|
||||
func Exclude[T comparable](vs []T, toExclude []T) []T {
|
||||
var ret []T
|
||||
for _, v := range vs {
|
||||
if !Include(toExclude, v) {
|
||||
ret = append(ret, v)
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func Index[T comparable](vs []T, t T) int {
|
||||
for i, v := range vs {
|
||||
if v == t {
|
||||
return i
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
func Include[T comparable](vs []T, t T) bool {
|
||||
return Index(vs, t) >= 0
|
||||
}
|
||||
|
||||
// IntAppendUnique appends toAdd to the vs int slice if toAdd does not already
|
||||
// exist in the slice. It returns the new or unchanged int slice.
|
||||
func AppendUnique[T comparable](vs []T, toAdd T) []T {
|
||||
if Include(vs, toAdd) {
|
||||
return vs
|
||||
}
|
||||
|
||||
return append(vs, toAdd)
|
||||
}
|
||||
|
||||
// IntAppendUniques appends a slice of values to the vs slice. It only
|
||||
// appends values that do not already exist in the slice. It returns the new or
|
||||
// unchanged slice.
|
||||
func AppendUniques[T comparable](vs []T, toAdd []T) []T {
|
||||
for _, v := range toAdd {
|
||||
vs = AppendUnique(vs, v)
|
||||
}
|
||||
|
||||
return vs
|
||||
}
|
||||
|
||||
// SliceSame returns true if the two provided lists have the same elements,
|
||||
// regardless of order. Panics if either parameter is not a slice.
|
||||
func SliceSame(a, b interface{}) bool {
|
||||
|
||||
Reference in New Issue
Block a user