From d7a26a2e6c0e12475c7e9d02b2bc774058b8cc4c Mon Sep 17 00:00:00 2001 From: kolaente Date: Thu, 29 Dec 2022 18:49:48 +0100 Subject: [PATCH] fix: make it compile again --- pkg/models/task_collection.go | 13 ++++++++----- pkg/routes/api/v1/user_list.go | 2 +- pkg/routes/routes.go | 1 - 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pkg/models/task_collection.go b/pkg/models/task_collection.go index 52263c5dd7..60e2c1fbca 100644 --- a/pkg/models/task_collection.go +++ b/pkg/models/task_collection.go @@ -24,8 +24,7 @@ import ( // TaskCollection is a struct used to hold filter details and not clutter the Task struct with information not related to actual tasks. type TaskCollection struct { - ProjectID int64 `param:"project" json:"-"` - Projects []*Project `json:"-"` + ProjectID int64 `param:"project" json:"-"` // The query parameter to sort by. This is for ex. done, priority, etc. SortBy []string `query:"sort_by" json:"sort_by"` @@ -178,8 +177,9 @@ func (tf *TaskCollection) ReadAll(s *xorm.Session, a web.Auth, search string, pa // If the project ID is not set, we get all tasks for the user. // This allows to use this function in Task.ReadAll with a possibility to deprecate the latter at some point. + var projects []*Project if tf.ProjectID == 0 { - tf.Projects, _, _, err = getRawProjectsForUser( + projectMap, _, _, err := getRawProjectsForUser( s, &projectOptions{ user: &user.User{ID: a.GetID()}, @@ -189,6 +189,9 @@ func (tf *TaskCollection) ReadAll(s *xorm.Session, a web.Auth, search string, pa if err != nil { return nil, 0, 0, err } + for _, project := range projectMap { + projects = append(projects, project) + } } else { // Check the project exists and the user has acess on it project := &Project{ID: tf.ProjectID} @@ -199,8 +202,8 @@ func (tf *TaskCollection) ReadAll(s *xorm.Session, a web.Auth, search string, pa if !canRead { return nil, 0, 0, ErrUserDoesNotHaveAccessToProject{ProjectID: tf.ProjectID} } - tf.Projects = []*Project{{ID: tf.ProjectID}} + projects = []*Project{{ID: tf.ProjectID}} } - return getTasksForProjects(s, tf.Projects, a, taskopts) + return getTasksForProjects(s, projects, a, taskopts) } diff --git a/pkg/routes/api/v1/user_list.go b/pkg/routes/api/v1/user_list.go index 7c6929a8a1..a30ccd851c 100644 --- a/pkg/routes/api/v1/user_list.go +++ b/pkg/routes/api/v1/user_list.go @@ -47,7 +47,7 @@ func UserProject(c echo.Context) error { s := db.NewSession() defer s.Close() - users, err := user.ProjectUsers(s, search, nil) + users, err := user.ListUsers(s, search, nil) if err != nil { _ = s.Rollback() return handler.HandleHTTPError(err, c) diff --git a/pkg/routes/routes.go b/pkg/routes/routes.go index 70a0714fab..aa86f3474f 100644 --- a/pkg/routes/routes.go +++ b/pkg/routes/routes.go @@ -69,7 +69,6 @@ import ( "code.vikunja.io/api/pkg/modules/migration/todoist" "code.vikunja.io/api/pkg/modules/migration/trello" vikunja_file "code.vikunja.io/api/pkg/modules/migration/vikunja-file" - "code.vikunja.io/api/pkg/modules/migration/wunderlist" apiv1 "code.vikunja.io/api/pkg/routes/api/v1" "code.vikunja.io/api/pkg/routes/caldav" _ "code.vikunja.io/api/pkg/swagger" // To generate swagger docs