1
0

fix(tasks): do not use typesense modified options to search with database

This commit is contained in:
kolaente 2024-07-11 12:41:40 +02:00
parent 5644130f01
commit 7f27cee6a3
No known key found for this signature in database
GPG Key ID: F40E70337AB24C9B

View File

@ -303,13 +303,14 @@ func getRawTasksForProjects(s *xorm.Session, projects []*Project, a web.Auth, op
var tsSearcher taskSearcher = &typesenseTaskSearcher{
s: s,
}
origOpts := *opts
tasks, totalItems, err = tsSearcher.Search(opts)
// It is possible that project views are not yet in Typesnse's index. This causes the query here to fail.
// To avoid crashing everything, we fall back to the db search in that case.
var tsErr = &typesense.HTTPError{}
if err != nil && errors.As(err, &tsErr) && tsErr.Status == 404 {
log.Warningf("Unable to fetch tasks from Typesense, error was '%v'. Falling back to db.", err)
tasks, totalItems, err = dbSearcher.Search(opts)
tasks, totalItems, err = dbSearcher.Search(&origOpts)
}
} else {
tasks, totalItems, err = dbSearcher.Search(opts)