diff --git a/go.mod b/go.mod index ae0f1778c..76a34adcd 100644 --- a/go.mod +++ b/go.mod @@ -116,6 +116,8 @@ require ( github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/hcl v1.0.0 // indirect + github.com/huandu/go-clone v1.6.0 // indirect + github.com/huandu/go-clone/generic v1.7.2 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect diff --git a/go.sum b/go.sum index 23979498d..62f33ed55 100644 --- a/go.sum +++ b/go.sum @@ -197,6 +197,11 @@ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T github.com/hhsnopek/etag v0.0.0-20171206181245-aea95f647346 h1:Odeq5rB6OZSkib5gqTG+EM1iF0bUVjYYd33XB1ULv00= github.com/hhsnopek/etag v0.0.0-20171206181245-aea95f647346/go.mod h1:4ggHM2qnyyZjenBb7RpwVzIj+JMsu9kHCVxMjB30hGs= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0JrPVhn/06U= +github.com/huandu/go-clone v1.6.0 h1:HMo5uvg4wgfiy5FoGOqlFLQED/VGRm2D9Pi8g1FXPGc= +github.com/huandu/go-clone v1.6.0/go.mod h1:ReGivhG6op3GYr+UY3lS6mxjKp7MIGTknuU5TbTVaXE= +github.com/huandu/go-clone/generic v1.7.2 h1:47pQphxs1Xc9cVADjOHN+Bm5D0hNagwH9UXErbxgVKA= +github.com/huandu/go-clone/generic v1.7.2/go.mod h1:xgd9ZebcMsBWWcBx5mVMCoqMX24gLWr5lQicr+nVXNs= github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20220319035150-800ac71e25c2/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= diff --git a/pkg/models/tasks.go b/pkg/models/tasks.go index 840727270..32e86cd14 100644 --- a/pkg/models/tasks.go +++ b/pkg/models/tasks.go @@ -18,6 +18,7 @@ package models import ( "errors" + clone "github.com/huandu/go-clone/generic" "math" "regexp" "sort" @@ -303,14 +304,14 @@ func getRawTasksForProjects(s *xorm.Session, projects []*Project, a web.Auth, op var tsSearcher taskSearcher = &typesenseTaskSearcher{ s: s, } - origOpts := *opts + origOpts := clone.Clone(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(&origOpts) + tasks, totalItems, err = dbSearcher.Search(origOpts) } } else { tasks, totalItems, err = dbSearcher.Search(opts)