Auto tag rewrite (#1324)

This commit is contained in:
WithoutPants
2021-04-26 12:51:31 +10:00
committed by GitHub
parent f66010a367
commit 2eb2d865dc
26 changed files with 1469 additions and 370 deletions

View File

@@ -3,6 +3,7 @@ package sqlite
import (
"database/sql"
"fmt"
"strings"
"github.com/stashapp/stash/pkg/models"
)
@@ -121,6 +122,23 @@ func (qb *studioQueryBuilder) All() ([]*models.Studio, error) {
return qb.queryStudios(selectAll("studios")+qb.getStudioSort(nil), nil)
}
func (qb *studioQueryBuilder) QueryForAutoTag(words []string) ([]*models.Studio, error) {
// TODO - Query needs to be changed to support queries of this type, and
// this method should be removed
query := selectAll(studioTable)
var whereClauses []string
var args []interface{}
for _, w := range words {
whereClauses = append(whereClauses, "name like ?")
args = append(args, "%"+w+"%")
}
where := strings.Join(whereClauses, " OR ")
return qb.queryStudios(query+" WHERE "+where, args)
}
func (qb *studioQueryBuilder) Query(studioFilter *models.StudioFilterType, findFilter *models.FindFilterType) ([]*models.Studio, int, error) {
if studioFilter == nil {
studioFilter = &models.StudioFilterType{}