Fix favorite tasks for related tasks
continuous-integration/drone/pr Build is failing Details

This commit is contained in:
kolaente 2021-07-10 11:59:16 +02:00
parent 790ecfef87
commit 783bda514f
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 9 additions and 2 deletions

View File

@ -622,7 +622,7 @@ func getTaskReminderMap(s *xorm.Session, taskIDs []int64) (taskReminders map[int
return
}
func addRelatedTasksToTasks(s *xorm.Session, taskIDs []int64, taskMap map[int64]*Task) (err error) {
func addRelatedTasksToTasks(s *xorm.Session, taskIDs []int64, taskMap map[int64]*Task, a web.Auth) (err error) {
relatedTasks := []*TaskRelation{}
err = s.In("task_id", taskIDs).Find(&relatedTasks)
if err != nil {
@ -645,10 +645,16 @@ func addRelatedTasksToTasks(s *xorm.Session, taskIDs []int64, taskMap map[int64]
return
}
taskFavorites, err := getFavorites(s, relatedTaskIDs, a, FavoriteKindTask)
if err != nil {
return err
}
// NOTE: while it certainly be possible to run this function on fullRelatedTasks again, we don't do this for performance reasons.
// Go through all task relations and put them into the task objects
for _, rt := range relatedTasks {
fullRelatedTasks[rt.OtherTaskID].IsFavorite = taskFavorites[rt.OtherTaskID]
taskMap[rt.TaskID].RelatedTasks[rt.RelationKind] = append(taskMap[rt.TaskID].RelatedTasks[rt.RelationKind], fullRelatedTasks[rt.OtherTaskID])
}
@ -729,7 +735,7 @@ func addMoreInfoToTasks(s *xorm.Session, taskMap map[int64]*Task, a web.Auth) (e
}
// Get all related tasks
err = addRelatedTasksToTasks(s, taskIDs, taskMap)
err = addRelatedTasksToTasks(s, taskIDs, taskMap, a)
return
}

View File

@ -60,6 +60,7 @@ func SetupTests() {
"buckets",
"saved_filters",
"subscriptions",
"favorites",
)
if err != nil {
log.Fatal(err)