mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
String regex filter criteria and selective autotag (#1082)
* Add regex string filter criterion * Use query interface for auto tagging * Use Query interface for filename parser * Remove query regex interfaces * Add selective auto tag * Use page size 0 as no limit
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
package sqlite
|
||||
|
||||
import "github.com/stashapp/stash/pkg/models"
|
||||
import (
|
||||
"regexp"
|
||||
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
)
|
||||
|
||||
type queryBuilder struct {
|
||||
repository *repository
|
||||
@@ -12,9 +16,15 @@ type queryBuilder struct {
|
||||
args []interface{}
|
||||
|
||||
sortAndPagination string
|
||||
|
||||
err error
|
||||
}
|
||||
|
||||
func (qb queryBuilder) executeFind() ([]int, int, error) {
|
||||
if qb.err != nil {
|
||||
return nil, 0, qb.err
|
||||
}
|
||||
|
||||
return qb.repository.executeFindQuery(qb.body, qb.args, qb.sortAndPagination, qb.whereClauses, qb.havingClauses)
|
||||
}
|
||||
|
||||
@@ -66,6 +76,20 @@ func (qb *queryBuilder) handleStringCriterionInput(c *models.StringCriterionInpu
|
||||
case models.CriterionModifierNotEquals:
|
||||
qb.addWhere(column + " NOT LIKE ?")
|
||||
qb.addArg(c.Value)
|
||||
case models.CriterionModifierMatchesRegex:
|
||||
if _, err := regexp.Compile(c.Value); err != nil {
|
||||
qb.err = err
|
||||
return
|
||||
}
|
||||
qb.addWhere(column + " regexp ?")
|
||||
qb.addArg(c.Value)
|
||||
case models.CriterionModifierNotMatchesRegex:
|
||||
if _, err := regexp.Compile(c.Value); err != nil {
|
||||
qb.err = err
|
||||
return
|
||||
}
|
||||
qb.addWhere(column + " NOT regexp ?")
|
||||
qb.addArg(c.Value)
|
||||
default:
|
||||
clause, count := getSimpleCriterionClause(modifier, "?")
|
||||
qb.addWhere(column + " " + clause)
|
||||
|
||||
Reference in New Issue
Block a user