mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Studio Performers page (#1405)
* Refactor performer filter * Add performer studio criterion * Add Studio Performers page
This commit is contained in:
@@ -100,6 +100,143 @@ func TestPerformerFindByNames(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestPerformerQueryEthnicityOr(t *testing.T) {
|
||||
const performer1Idx = 1
|
||||
const performer2Idx = 2
|
||||
|
||||
performer1Eth := getPerformerStringValue(performer1Idx, "Ethnicity")
|
||||
performer2Eth := getPerformerStringValue(performer2Idx, "Ethnicity")
|
||||
|
||||
performerFilter := models.PerformerFilterType{
|
||||
Ethnicity: &models.StringCriterionInput{
|
||||
Value: performer1Eth,
|
||||
Modifier: models.CriterionModifierEquals,
|
||||
},
|
||||
Or: &models.PerformerFilterType{
|
||||
Ethnicity: &models.StringCriterionInput{
|
||||
Value: performer2Eth,
|
||||
Modifier: models.CriterionModifierEquals,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
withTxn(func(r models.Repository) error {
|
||||
sqb := r.Performer()
|
||||
|
||||
performers := queryPerformers(t, sqb, &performerFilter, nil)
|
||||
|
||||
assert.Len(t, performers, 2)
|
||||
assert.Equal(t, performer1Eth, performers[0].Ethnicity.String)
|
||||
assert.Equal(t, performer2Eth, performers[1].Ethnicity.String)
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func TestPerformerQueryEthnicityAndRating(t *testing.T) {
|
||||
const performerIdx = 1
|
||||
performerEth := getPerformerStringValue(performerIdx, "Ethnicity")
|
||||
performerRating := getRating(performerIdx)
|
||||
|
||||
performerFilter := models.PerformerFilterType{
|
||||
Ethnicity: &models.StringCriterionInput{
|
||||
Value: performerEth,
|
||||
Modifier: models.CriterionModifierEquals,
|
||||
},
|
||||
And: &models.PerformerFilterType{
|
||||
Rating: &models.IntCriterionInput{
|
||||
Value: int(performerRating.Int64),
|
||||
Modifier: models.CriterionModifierEquals,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
withTxn(func(r models.Repository) error {
|
||||
sqb := r.Performer()
|
||||
|
||||
performers := queryPerformers(t, sqb, &performerFilter, nil)
|
||||
|
||||
assert.Len(t, performers, 1)
|
||||
assert.Equal(t, performerEth, performers[0].Ethnicity.String)
|
||||
assert.Equal(t, performerRating.Int64, performers[0].Rating.Int64)
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func TestPerformerQueryPathNotRating(t *testing.T) {
|
||||
const performerIdx = 1
|
||||
|
||||
performerRating := getRating(performerIdx)
|
||||
|
||||
ethCriterion := models.StringCriterionInput{
|
||||
Value: "performer_.*1_Ethnicity",
|
||||
Modifier: models.CriterionModifierMatchesRegex,
|
||||
}
|
||||
|
||||
ratingCriterion := models.IntCriterionInput{
|
||||
Value: int(performerRating.Int64),
|
||||
Modifier: models.CriterionModifierEquals,
|
||||
}
|
||||
|
||||
performerFilter := models.PerformerFilterType{
|
||||
Ethnicity: ðCriterion,
|
||||
Not: &models.PerformerFilterType{
|
||||
Rating: &ratingCriterion,
|
||||
},
|
||||
}
|
||||
|
||||
withTxn(func(r models.Repository) error {
|
||||
sqb := r.Performer()
|
||||
|
||||
performers := queryPerformers(t, sqb, &performerFilter, nil)
|
||||
|
||||
for _, performer := range performers {
|
||||
verifyString(t, performer.Ethnicity.String, ethCriterion)
|
||||
ratingCriterion.Modifier = models.CriterionModifierNotEquals
|
||||
verifyInt64(t, performer.Rating, ratingCriterion)
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func TestPerformerIllegalQuery(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
const performerIdx = 1
|
||||
subFilter := models.PerformerFilterType{
|
||||
Ethnicity: &models.StringCriterionInput{
|
||||
Value: getPerformerStringValue(performerIdx, "Ethnicity"),
|
||||
Modifier: models.CriterionModifierEquals,
|
||||
},
|
||||
}
|
||||
|
||||
performerFilter := &models.PerformerFilterType{
|
||||
And: &subFilter,
|
||||
Or: &subFilter,
|
||||
}
|
||||
|
||||
withTxn(func(r models.Repository) error {
|
||||
sqb := r.Performer()
|
||||
|
||||
_, _, err := sqb.Query(performerFilter, nil)
|
||||
assert.NotNil(err)
|
||||
|
||||
performerFilter.Or = nil
|
||||
performerFilter.Not = &subFilter
|
||||
_, _, err = sqb.Query(performerFilter, nil)
|
||||
assert.NotNil(err)
|
||||
|
||||
performerFilter.And = nil
|
||||
performerFilter.Or = &subFilter
|
||||
_, _, err = sqb.Query(performerFilter, nil)
|
||||
assert.NotNil(err)
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func TestPerformerQueryForAutoTag(t *testing.T) {
|
||||
withTxn(func(r models.Repository) error {
|
||||
tqb := r.Performer()
|
||||
@@ -595,6 +732,58 @@ func verifyPerformersGalleryCount(t *testing.T, galleryCountCriterion models.Int
|
||||
})
|
||||
}
|
||||
|
||||
func TestPerformerQueryStudio(t *testing.T) {
|
||||
withTxn(func(r models.Repository) error {
|
||||
testCases := []struct {
|
||||
studioIndex int
|
||||
performerIndex int
|
||||
}{
|
||||
{studioIndex: studioIdxWithScenePerformer, performerIndex: performerIdxWithSceneStudio},
|
||||
{studioIndex: studioIdxWithImagePerformer, performerIndex: performerIdxWithImageStudio},
|
||||
{studioIndex: studioIdxWithGalleryPerformer, performerIndex: performerIdxWithGalleryStudio},
|
||||
}
|
||||
|
||||
sqb := r.Performer()
|
||||
|
||||
for _, tc := range testCases {
|
||||
studioCriterion := models.MultiCriterionInput{
|
||||
Value: []string{
|
||||
strconv.Itoa(studioIDs[tc.studioIndex]),
|
||||
},
|
||||
Modifier: models.CriterionModifierIncludes,
|
||||
}
|
||||
|
||||
performerFilter := models.PerformerFilterType{
|
||||
Studios: &studioCriterion,
|
||||
}
|
||||
|
||||
performers := queryPerformers(t, sqb, &performerFilter, nil)
|
||||
|
||||
assert.Len(t, performers, 1)
|
||||
|
||||
// ensure id is correct
|
||||
assert.Equal(t, performerIDs[tc.performerIndex], performers[0].ID)
|
||||
|
||||
studioCriterion = models.MultiCriterionInput{
|
||||
Value: []string{
|
||||
strconv.Itoa(studioIDs[tc.studioIndex]),
|
||||
},
|
||||
Modifier: models.CriterionModifierExcludes,
|
||||
}
|
||||
|
||||
q := getPerformerStringValue(tc.performerIndex, "Name")
|
||||
findFilter := models.FindFilterType{
|
||||
Q: &q,
|
||||
}
|
||||
|
||||
performers = queryPerformers(t, sqb, &performerFilter, &findFilter)
|
||||
assert.Len(t, performers, 0)
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func TestPerformerStashIDs(t *testing.T) {
|
||||
if err := withTxn(func(r models.Repository) error {
|
||||
qb := r.Performer()
|
||||
|
||||
Reference in New Issue
Block a user