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:
WithoutPants
2023-07-12 11:51:52 +10:00
committed by GitHub
parent 76a4bfa49a
commit 67d4f9729a
50 changed files with 978 additions and 205 deletions

View File

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