fix(typesense): do not try to sort by position when searching in a saved filter
This change fixes a bug where Typesense would try to sort by the project view of a saved filter. The view position is not indexed in Typesense, hence filtering fails. Because sorting by position is not a feature in saved filters, I've removed the logic for sorting saved filters with Typesense.
This commit is contained in:
parent
506ce66434
commit
e56b2232bb
@ -262,6 +262,7 @@ func (tf *TaskCollection) ReadAll(s *xorm.Session, a web.Auth, search string, pa
|
|||||||
opts.page = page
|
opts.page = page
|
||||||
opts.perPage = perPage
|
opts.perPage = perPage
|
||||||
opts.expand = tf.Expand
|
opts.expand = tf.Expand
|
||||||
|
opts.isSavedFilter = tf.isSavedFilter
|
||||||
|
|
||||||
if view != nil {
|
if view != nil {
|
||||||
var hasOrderByPosition bool
|
var hasOrderByPosition bool
|
||||||
|
@ -517,7 +517,13 @@ func (t *typesenseTaskSearcher) Search(opts *taskSearchOptions) (tasks []*Task,
|
|||||||
}
|
}
|
||||||
|
|
||||||
var sortbyFields []string
|
var sortbyFields []string
|
||||||
for i, param := range opts.sortby {
|
var usedParams int
|
||||||
|
for _, param := range opts.sortby {
|
||||||
|
|
||||||
|
if opts.isSavedFilter && param.sortBy == taskPropertyPosition {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// Validate the params
|
// Validate the params
|
||||||
if err := param.validate(); err != nil {
|
if err := param.validate(); err != nil {
|
||||||
return nil, totalCount, err
|
return nil, totalCount, err
|
||||||
@ -536,11 +542,13 @@ func (t *typesenseTaskSearcher) Search(opts *taskSearchOptions) (tasks []*Task,
|
|||||||
|
|
||||||
sortbyFields = append(sortbyFields, sortBy+"(missing_values:last):"+param.orderBy.String())
|
sortbyFields = append(sortbyFields, sortBy+"(missing_values:last):"+param.orderBy.String())
|
||||||
|
|
||||||
if i == 2 {
|
if usedParams == 2 {
|
||||||
// Typesense supports up to 3 sorting parameters
|
// Typesense supports up to 3 sorting parameters
|
||||||
// https://typesense.org/docs/0.25.0/api/search.html#ranking-and-sorting-parameters
|
// https://typesense.org/docs/0.25.0/api/search.html#ranking-and-sorting-parameters
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
usedParams++
|
||||||
}
|
}
|
||||||
|
|
||||||
sortby := strings.Join(sortbyFields, ",")
|
sortby := strings.Join(sortbyFields, ",")
|
||||||
|
@ -175,6 +175,7 @@ type taskSearchOptions struct {
|
|||||||
filterIncludeNulls bool
|
filterIncludeNulls bool
|
||||||
filter string
|
filter string
|
||||||
filterTimezone string
|
filterTimezone string
|
||||||
|
isSavedFilter bool
|
||||||
projectIDs []int64
|
projectIDs []int64
|
||||||
expand TaskCollectionExpandable
|
expand TaskCollectionExpandable
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user