diff --git a/db/sql/template.go b/db/sql/template.go index e7176f947..6ad7ee0d2 100644 --- a/db/sql/template.go +++ b/db/sql/template.go @@ -202,22 +202,20 @@ func (d *SqlDb) GetTemplates(projectID int, filter db.TemplateFilter, params db. for _, tpl := range tpls { template := tpl.Template - if tpl.LastTaskID == nil { - continue - } - - for _, tsk := range tasks { - if tsk.ID != *tpl.LastTaskID { - continue - } - err = tsk.Fill(d) - if err != nil { - return + if tpl.LastTaskID != nil { + for _, tsk := range tasks { + if tsk.ID == *tpl.LastTaskID { + err = tsk.Fill(d) + if err != nil { + return + } + template.LastTask = &tsk + break + } } - template.LastTask = &tsk - break } + templates = append(templates, template) }