From f843359ba3656ae78d4fbbe321e725f776145bc2 Mon Sep 17 00:00:00 2001 From: WithoutPants <53250216+WithoutPants@users.noreply.github.com> Date: Tue, 8 Jun 2021 10:47:22 +1000 Subject: [PATCH] Handle auto-tagging where filename has no whitespace in name (#1488) --- pkg/autotag/tagger.go | 8 +++++++- pkg/sqlite/performer.go | 4 ++-- pkg/sqlite/studio.go | 2 +- pkg/sqlite/tag.go | 2 +- ui/v2.5/src/components/Changelog/versions/v080.md | 1 + 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/pkg/autotag/tagger.go b/pkg/autotag/tagger.go index 9d2759f6c..4bca225c0 100644 --- a/pkg/autotag/tagger.go +++ b/pkg/autotag/tagger.go @@ -87,7 +87,13 @@ func getPathWords(path string) []string { var ret []string for _, w := range words { if len(w) > 1 { - ret = append(ret, w) + // #1450 - we need to open up the criteria for matching so that we + // can match where path has no space between subject names - + // ie name = "foo bar" - path = "foobar" + // we post-match afterwards, so we can afford to be a little loose + // with the query + // just use the first two characters + ret = append(ret, w[0:2]) } } diff --git a/pkg/sqlite/performer.go b/pkg/sqlite/performer.go index 2b6c8d4dd..e02a8525e 100644 --- a/pkg/sqlite/performer.go +++ b/pkg/sqlite/performer.go @@ -185,9 +185,9 @@ func (qb *performerQueryBuilder) QueryForAutoTag(words []string) ([]*models.Perf for _, w := range words { whereClauses = append(whereClauses, "name like ?") - args = append(args, "%"+w+"%") + args = append(args, w+"%") whereClauses = append(whereClauses, "aliases like ?") - args = append(args, "%"+w+"%") + args = append(args, w+"%") } where := strings.Join(whereClauses, " OR ") diff --git a/pkg/sqlite/studio.go b/pkg/sqlite/studio.go index 76099481e..31f371736 100644 --- a/pkg/sqlite/studio.go +++ b/pkg/sqlite/studio.go @@ -132,7 +132,7 @@ func (qb *studioQueryBuilder) QueryForAutoTag(words []string) ([]*models.Studio, for _, w := range words { whereClauses = append(whereClauses, "name like ?") - args = append(args, "%"+w+"%") + args = append(args, w+"%") } where := strings.Join(whereClauses, " OR ") diff --git a/pkg/sqlite/tag.go b/pkg/sqlite/tag.go index 811593efc..40c8f055d 100644 --- a/pkg/sqlite/tag.go +++ b/pkg/sqlite/tag.go @@ -214,7 +214,7 @@ func (qb *tagQueryBuilder) QueryForAutoTag(words []string) ([]*models.Tag, error var args []interface{} for _, w := range words { - ww := "%" + w + "%" + ww := w + "%" whereClauses = append(whereClauses, "tags.name like ?") args = append(args, ww) diff --git a/ui/v2.5/src/components/Changelog/versions/v080.md b/ui/v2.5/src/components/Changelog/versions/v080.md index fffc6df71..df3f02543 100644 --- a/ui/v2.5/src/components/Changelog/versions/v080.md +++ b/ui/v2.5/src/components/Changelog/versions/v080.md @@ -18,6 +18,7 @@ * Add button to remove studio stash ID. ([#1378](https://github.com/stashapp/stash/pull/1378)) ### 🐛 Bug fixes +* Fix auto-tagger not tagging scenes with no whitespace in name. ([#1488](https://github.com/stashapp/stash/pull/1488)) * Fix click/drag to select scenes. ([#1476](https://github.com/stashapp/stash/pull/1476)) * Fix clearing Performer and Movie ratings not working. ([#1429](https://github.com/stashapp/stash/pull/1429)) * Fix scraper date parser failing when parsing time. ([#1431](https://github.com/stashapp/stash/pull/1431))