String regex filter criteria and selective autotag (#1082)

* Add regex string filter criterion
* Use query interface for auto tagging
* Use Query interface for filename parser
* Remove query regex interfaces
* Add selective auto tag
* Use page size 0 as no limit
This commit is contained in:
WithoutPants
2021-02-02 07:57:56 +11:00
committed by GitHub
parent 4fd022a93b
commit e4d91a0226
24 changed files with 354 additions and 204 deletions

View File

@@ -114,13 +114,20 @@ func TestImageQueryPath(t *testing.T) {
Modifier: models.CriterionModifierEquals,
}
verifyImagePath(t, pathCriterion)
verifyImagePath(t, pathCriterion, 1)
pathCriterion.Modifier = models.CriterionModifierNotEquals
verifyImagePath(t, pathCriterion)
verifyImagePath(t, pathCriterion, totalImages-1)
pathCriterion.Modifier = models.CriterionModifierMatchesRegex
pathCriterion.Value = "image_.*1_Path"
verifyImagePath(t, pathCriterion, 1) // TODO - 2 if zip path is included
pathCriterion.Modifier = models.CriterionModifierNotMatchesRegex
verifyImagePath(t, pathCriterion, totalImages-1) // TODO - -2 if zip path is included
}
func verifyImagePath(t *testing.T, pathCriterion models.StringCriterionInput) {
func verifyImagePath(t *testing.T, pathCriterion models.StringCriterionInput, expected int) {
withTxn(func(r models.Repository) error {
sqb := r.Image()
imageFilter := models.ImageFilterType{
@@ -132,6 +139,8 @@ func verifyImagePath(t *testing.T, pathCriterion models.StringCriterionInput) {
t.Errorf("Error querying image: %s", err.Error())
}
assert.Equal(t, expected, len(images), "number of returned images")
for _, image := range images {
verifyString(t, image.Path, pathCriterion)
}