mirror of
https://github.com/stashapp/stash.git
synced 2026-02-25 00:33:03 +01:00
Add group scene count filter (#6593)
This commit is contained in:
parent
c15e6a5b63
commit
843806247d
5 changed files with 42 additions and 0 deletions
|
|
@ -455,6 +455,8 @@ input GroupFilterType {
|
|||
containing_group_count: IntCriterionInput
|
||||
"Filter by number of sub-groups the group has"
|
||||
sub_group_count: IntCriterionInput
|
||||
"Filter by number of scenes the group has"
|
||||
scene_count: IntCriterionInput
|
||||
|
||||
"Filter by related scenes that meet this criteria"
|
||||
scenes_filter: SceneFilterType
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ type GroupFilterType struct {
|
|||
ContainingGroupCount *IntCriterionInput `json:"containing_group_count"`
|
||||
// Filter by number of sub-groups the group has
|
||||
SubGroupCount *IntCriterionInput `json:"sub_group_count"`
|
||||
// Filter by number of scenes the group has
|
||||
SceneCount *IntCriterionInput `json:"scene_count"`
|
||||
// Filter by related scenes that meet this criteria
|
||||
ScenesFilter *SceneFilterType `json:"scenes_filter"`
|
||||
// Filter by related studios that meet this criteria
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ func (qb *groupFilterHandler) criterionHandler() criterionHandler {
|
|||
qb.tagsCriterionHandler(groupFilter.Tags),
|
||||
qb.tagCountCriterionHandler(groupFilter.TagCount),
|
||||
qb.groupOCounterCriterionHandler(groupFilter.OCounter),
|
||||
qb.sceneCountCriterionHandler(groupFilter.SceneCount),
|
||||
&dateCriterionHandler{groupFilter.Date, "groups.date", nil},
|
||||
groupHierarchyHandler.ParentsCriterionHandler(groupFilter.ContainingGroups),
|
||||
groupHierarchyHandler.ChildrenCriterionHandler(groupFilter.SubGroups),
|
||||
|
|
@ -204,6 +205,16 @@ func (qb *groupFilterHandler) tagCountCriterionHandler(count *models.IntCriterio
|
|||
return h.handler(count)
|
||||
}
|
||||
|
||||
func (qb *groupFilterHandler) sceneCountCriterionHandler(count *models.IntCriterionInput) criterionHandlerFunc {
|
||||
h := countCriterionHandlerBuilder{
|
||||
primaryTable: groupTable,
|
||||
joinTable: groupsScenesTable,
|
||||
primaryFK: groupIDColumn,
|
||||
}
|
||||
|
||||
return h.handler(count)
|
||||
}
|
||||
|
||||
// used for sorting and filtering on group o-count
|
||||
var selectGroupOCountSQL = utils.StrFormat(
|
||||
"SELECT SUM(o_counter) "+
|
||||
|
|
|
|||
|
|
@ -669,6 +669,32 @@ func TestGroupQuery(t *testing.T) {
|
|||
nil,
|
||||
false,
|
||||
},
|
||||
{
|
||||
"scene count equals 1",
|
||||
nil,
|
||||
&models.GroupFilterType{
|
||||
SceneCount: &models.IntCriterionInput{
|
||||
Value: 1,
|
||||
Modifier: models.CriterionModifierEquals,
|
||||
},
|
||||
},
|
||||
[]int{groupIdxWithScene},
|
||||
[]int{groupIdxWithParentAndChild},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"scene count less than 1",
|
||||
nil,
|
||||
&models.GroupFilterType{
|
||||
SceneCount: &models.IntCriterionInput{
|
||||
Value: 1,
|
||||
Modifier: models.CriterionModifierLessThan,
|
||||
},
|
||||
},
|
||||
[]int{groupIdxWithParentAndChild},
|
||||
[]int{groupIdxWithScene},
|
||||
false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ const criterionOptions = [
|
|||
createMandatoryNumberCriterionOption("sub_group_count"),
|
||||
TagsCriterionOption,
|
||||
createMandatoryNumberCriterionOption("tag_count"),
|
||||
createMandatoryNumberCriterionOption("scene_count"),
|
||||
createMandatoryTimestampCriterionOption("created_at"),
|
||||
createMandatoryTimestampCriterionOption("updated_at"),
|
||||
];
|
||||
|
|
|
|||
Loading…
Reference in a new issue