mirror of
https://github.com/stashapp/stash.git
synced 2026-04-24 16:04:56 +02:00
Add scene & image filtering by filename
This commit is contained in:
parent
a0e09bbe5c
commit
096c62c620
9 changed files with 26 additions and 2 deletions
|
|
@ -230,6 +230,8 @@ input SceneFilterType {
|
|||
phash_distance: PhashDistanceCriterionInput
|
||||
"Filter by path"
|
||||
path: StringCriterionInput
|
||||
"Filter by filename/basename"
|
||||
filename: StringCriterionInput
|
||||
"Filter by file count"
|
||||
file_count: IntCriterionInput
|
||||
# rating expressed as 1-100
|
||||
|
|
@ -613,6 +615,8 @@ input ImageFilterType {
|
|||
checksum: StringCriterionInput
|
||||
"Filter by path"
|
||||
path: StringCriterionInput
|
||||
"Filter by filename/basename"
|
||||
filename: StringCriterionInput
|
||||
"Filter by file count"
|
||||
file_count: IntCriterionInput
|
||||
# rating expressed as 1-100
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ type ImageFilterType struct {
|
|||
Checksum *StringCriterionInput `json:"checksum"`
|
||||
// Filter by path
|
||||
Path *StringCriterionInput `json:"path"`
|
||||
// Filter by filename/basename
|
||||
Filename *StringCriterionInput `json:"filename"`
|
||||
// Filter by file count
|
||||
FileCount *IntCriterionInput `json:"file_count"`
|
||||
// Filter by rating expressed as 1-100
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ type SceneFilterType struct {
|
|||
PhashDistance *PhashDistanceCriterionInput `json:"phash_distance"`
|
||||
// Filter by path
|
||||
Path *StringCriterionInput `json:"path"`
|
||||
// Filter by filename/basename
|
||||
Filename *StringCriterionInput `json:"filename"`
|
||||
// Filter by file count
|
||||
FileCount *IntCriterionInput `json:"file_count"`
|
||||
// Filter by rating expressed as 1-100
|
||||
|
|
|
|||
|
|
@ -93,6 +93,17 @@ func enumCriterionHandler(modifier models.CriterionModifier, values []string, co
|
|||
}
|
||||
}
|
||||
|
||||
func filenameCriterionHandler(c *models.StringCriterionInput, basenameColumn string, addJoinFn func(f *filterBuilder)) criterionHandlerFunc {
|
||||
return func(ctx context.Context, f *filterBuilder) {
|
||||
if c != nil {
|
||||
if addJoinFn != nil {
|
||||
addJoinFn(f)
|
||||
}
|
||||
stringCriterionHandler(c, basenameColumn)(ctx, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func pathCriterionHandler(c *models.StringCriterionInput, pathColumn string, basenameColumn string, addJoinFn func(f *filterBuilder)) criterionHandlerFunc {
|
||||
return func(ctx context.Context, f *filterBuilder) {
|
||||
if c != nil {
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ func (qb *imageFilterHandler) criterionHandler() criterionHandler {
|
|||
stringCriterionHandler(imageFilter.Photographer, "images.photographer"),
|
||||
|
||||
pathCriterionHandler(imageFilter.Path, "folders.path", "files.basename", imageRepository.addFoldersTable),
|
||||
filenameCriterionHandler(imageFilter.Filename, "files.basename", imageRepository.addImagesFilesTable),
|
||||
qb.fileCountCriterionHandler(imageFilter.FileCount),
|
||||
intCriterionHandler(imageFilter.Rating100, "images.rating", nil),
|
||||
intCriterionHandler(imageFilter.OCounter, "images.o_counter", nil),
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ func (qb *sceneFilterHandler) criterionHandler() criterionHandler {
|
|||
return compoundHandler{
|
||||
intCriterionHandler(sceneFilter.ID, "scenes.id", nil),
|
||||
pathCriterionHandler(sceneFilter.Path, "folders.path", "files.basename", qb.addFoldersTable),
|
||||
filenameCriterionHandler(sceneFilter.Filename, "files.basename", qb.addFilesTable),
|
||||
qb.fileCountCriterionHandler(sceneFilter.FileCount),
|
||||
stringCriterionHandler(sceneFilter.Title, "scenes.title"),
|
||||
stringCriterionHandler(sceneFilter.Code, "scenes.code"),
|
||||
|
|
@ -383,8 +384,8 @@ func (qb *sceneFilterHandler) captionCriterionHandler(captions *models.StringCri
|
|||
},
|
||||
excludeHandler: func(f *filterBuilder, criterion *models.StringCriterionInput) {
|
||||
excludeClause := `scenes.id NOT IN (
|
||||
SELECT scenes_files.scene_id from scenes_files
|
||||
INNER JOIN video_captions on video_captions.file_id = scenes_files.file_id
|
||||
SELECT scenes_files.scene_id from scenes_files
|
||||
INNER JOIN video_captions on video_captions.file_id = scenes_files.file_id
|
||||
WHERE video_captions.language_code LIKE ?
|
||||
)`
|
||||
f.addWhere(excludeClause, criterion.Value)
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ const criterionOptions = [
|
|||
createStringCriterionOption("photographer"),
|
||||
createMandatoryStringCriterionOption("checksum", "media_info.checksum"),
|
||||
PathCriterionOption,
|
||||
createStringCriterionOption("filename", "component_tagger.config.query_mode_filename"),
|
||||
GalleriesCriterionOption,
|
||||
OrganizedCriterionOption,
|
||||
createMandatoryNumberCriterionOption("o_counter", "o_count"),
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ const criterionOptions = [
|
|||
createStringCriterionOption("title"),
|
||||
createStringCriterionOption("code", "scene_code"),
|
||||
PathCriterionOption,
|
||||
createStringCriterionOption("filename", "component_tagger.config.query_mode_filename"),
|
||||
createStringCriterionOption("details"),
|
||||
createStringCriterionOption("director"),
|
||||
createMandatoryStringCriterionOption("oshash", "media_info.hash"),
|
||||
|
|
|
|||
|
|
@ -125,6 +125,7 @@ export interface IOptionType {
|
|||
|
||||
export type CriterionType =
|
||||
| "path"
|
||||
| "filename"
|
||||
| "rating100"
|
||||
| "organized"
|
||||
| "o_counter"
|
||||
|
|
|
|||
Loading…
Reference in a new issue