Performer disambiguation and aliases (#3113)

* Refactor performer relationships
* Remove checksum from performer
* Add disambiguation, overhaul aliases
* Add disambiguation filter criterion
* Improve name matching during import
* Add disambiguation filtering in UI
* Include aliases in performer select
This commit is contained in:
WithoutPants
2022-12-01 13:54:08 +11:00
committed by GitHub
parent d2395e579c
commit 4daf0a14a2
72 changed files with 2283 additions and 993 deletions

View File

@@ -1,6 +1,9 @@
package stringslice
import "strconv"
import (
"strconv"
"strings"
)
// https://gobyexample.com/collection-functions
@@ -56,6 +59,19 @@ func StrAppendUniques(vs []string, toAdd []string) []string {
return vs
}
// StrExclude removes all instances of any value in toExclude from the vs string
// slice. It returns the new or unchanged string slice.
func StrExclude(vs []string, toExclude []string) []string {
var ret []string
for _, v := range vs {
if !StrInclude(toExclude, v) {
ret = append(ret, v)
}
}
return ret
}
// StrUnique returns the vs string slice with non-unique values removed.
func StrUnique(vs []string) []string {
distinctValues := make(map[string]struct{})
@@ -94,3 +110,13 @@ func StringSliceToIntSlice(ss []string) ([]int, error) {
return ret, nil
}
// FromString converts a string to a slice of strings, splitting on the sep character.
// Unlike strings.Split, this function will also trim whitespace from the resulting strings.
func FromString(s string, sep string) []string {
v := strings.Split(s, ",")
for i, vv := range v {
v[i] = strings.TrimSpace(vv)
}
return v
}