Refactored getting task IDs for labels

This commit is contained in:
kolaente 2019-10-20 17:55:54 +02:00
parent 48e422b379
commit eb279fdba3
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
2 changed files with 13 additions and 3 deletions

View file

@ -203,7 +203,7 @@ func getUserTaskIDs(u *User) (taskIDs []int64, err error) {
return nil, err
}
tasks, err := getTasksForLists(lists, &taskOptions{
tasks, err := getRawTasksForLists(lists, &taskOptions{
startDate: time.Unix(0, 0),
endDate: time.Unix(0, 0),
sortby: SortTasksByUnsorted,

View file

@ -184,7 +184,8 @@ type taskOptions struct {
endDate time.Time
}
func getTasksForLists(lists []*List, opts *taskOptions) (tasks []*Task, err error) {
func getRawTasksForLists(lists []*List, opts *taskOptions) (taskMap map[int64]*Task, err error) {
// Get all list IDs and get the tasks
var listIDs []int64
for _, l := range lists {
@ -203,7 +204,7 @@ func getTasksForLists(lists []*List, opts *taskOptions) (tasks []*Task, err erro
orderby = "due_date_unix asc"
}
taskMap := make(map[int64]*Task)
taskMap = make(map[int64]*Task)
// Then return all tasks for that lists
if opts.startDate.Unix() != 0 || opts.endDate.Unix() != 0 {
@ -235,6 +236,15 @@ func getTasksForLists(lists []*List, opts *taskOptions) (tasks []*Task, err erro
return nil, err
}
}
return
}
func getTasksForLists(lists []*List, opts *taskOptions) (tasks []*Task, err error) {
taskMap, err := getRawTasksForLists(lists, opts)
if err != nil {
return nil, err
}
tasks, err = addMoreInfoToTasks(taskMap)
if err != nil {