mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
added support for image orientation filter (#4404)
* added support for image orientation filter * Add orientation filtering to scenes --------- Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
43
pkg/sqlite/criterion_handlers.go
Normal file
43
pkg/sqlite/criterion_handlers.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package sqlite
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
)
|
||||
|
||||
// shared criterion handlers go here
|
||||
|
||||
func orientationCriterionHandler(orientation *models.OrientationCriterionInput, heightColumn string, widthColumn string, addJoinFn func(f *filterBuilder)) criterionHandlerFunc {
|
||||
return func(ctx context.Context, f *filterBuilder) {
|
||||
if orientation != nil {
|
||||
if addJoinFn != nil {
|
||||
addJoinFn(f)
|
||||
}
|
||||
|
||||
var clauses []sqlClause
|
||||
|
||||
for _, v := range orientation.Value {
|
||||
// width mod height
|
||||
mod := ""
|
||||
switch v {
|
||||
case models.OrientationPortrait:
|
||||
mod = "<"
|
||||
case models.OrientationLandscape:
|
||||
mod = ">"
|
||||
case models.OrientationSquare:
|
||||
mod = "="
|
||||
}
|
||||
|
||||
if mod != "" {
|
||||
clauses = append(clauses, makeClause(fmt.Sprintf("%s %s %s", widthColumn, mod, heightColumn)))
|
||||
}
|
||||
}
|
||||
|
||||
if len(clauses) > 0 {
|
||||
f.whereClauses = append(f.whereClauses, orClauses(clauses...))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user