Fix getting all buckets
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
kolaente 2021-02-28 23:15:28 +01:00
parent 9c9cbca11a
commit b82d0af1ac
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
4 changed files with 7 additions and 4 deletions

View File

@ -144,10 +144,11 @@ func (b *Bucket) ReadAll(s *xorm.Session, auth web.Auth, search string, page int
opts.page = page
opts.perPage = perPage
opts.search = search
opts.filterConcat = filterConcatAnd
var bucketFilterIndex int
for i, filter := range opts.filters {
if filter.field == "bucket_id" {
if filter.field == taskPropertyBucketID {
bucketFilterIndex = i
break
}
@ -155,7 +156,7 @@ func (b *Bucket) ReadAll(s *xorm.Session, auth web.Auth, search string, page int
if bucketFilterIndex == 0 {
opts.filters = append(opts.filters, &taskFilter{
field: "bucket_id",
field: taskPropertyBucketID,
value: 0,
comparator: taskFilterComparatorEquals,
})

View File

@ -82,7 +82,7 @@ func TestBucket_ReadAll(t *testing.T) {
FilterValue: []string{"done"},
},
}
bucketsInterface, _, _, err := b.ReadAll(s, testuser, "", 0, 0)
bucketsInterface, _, _, err := b.ReadAll(s, testuser, "", -1, 0)
assert.NoError(t, err)
buckets := bucketsInterface.([]*Bucket)

View File

@ -72,7 +72,8 @@ func validateTaskField(fieldName string) error {
taskPropertyUID,
taskPropertyCreated,
taskPropertyUpdated,
taskPropertyPosition:
taskPropertyPosition,
taskPropertyBucketID:
return nil
}
return ErrInvalidTaskField{TaskField: fieldName}

View File

@ -44,6 +44,7 @@ const (
taskPropertyCreated string = "created"
taskPropertyUpdated string = "updated"
taskPropertyPosition string = "position"
taskPropertyBucketID string = "bucket_id"
)
const (