Tag aliases (#1412)

* Add Tag Update/UpdateFull
* Tag alias implementation
* Refactor tag page
* Add aliases in UI
* Include tag aliases in q filter
* Include aliases in tag select
* Add aliases to auto-tagger
* Use aliases in scraper
* Add tag aliases for filename parser
This commit is contained in:
WithoutPants
2021-05-26 14:36:05 +10:00
committed by GitHub
parent 9b57fbbf50
commit c70faa2a53
48 changed files with 1303 additions and 315 deletions

View File

@@ -343,6 +343,45 @@ func (r *imageRepository) replace(id int, image []byte) error {
return err
}
type stringRepository struct {
repository
stringColumn string
}
func (r *stringRepository) get(id int) ([]string, error) {
query := fmt.Sprintf("SELECT %s from %s WHERE %s = ?", r.stringColumn, r.tableName, r.idColumn)
var ret []string
err := r.queryFunc(query, []interface{}{id}, func(rows *sqlx.Rows) error {
var out string
if err := rows.Scan(&out); err != nil {
return err
}
ret = append(ret, out)
return nil
})
return ret, err
}
func (r *stringRepository) insert(id int, s string) (sql.Result, error) {
stmt := fmt.Sprintf("INSERT INTO %s (%s, %s) VALUES (?, ?)", r.tableName, r.idColumn, r.stringColumn)
return r.tx.Exec(stmt, id, s)
}
func (r *stringRepository) replace(id int, newStrings []string) error {
if err := r.destroy([]int{id}); err != nil {
return err
}
for _, s := range newStrings {
if _, err := r.insert(id, s); err != nil {
return err
}
}
return nil
}
type stashIDRepository struct {
repository
}