From 24bc4a83b8f1c75a870e2b88b980454dddb61b2e Mon Sep 17 00:00:00 2001 From: Denis Gukov Date: Mon, 22 Jul 2024 00:00:31 +0500 Subject: [PATCH] fix(be): sql query --- db/sql/template.go | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/db/sql/template.go b/db/sql/template.go index e7176f94..6ad7ee0d 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 + + 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 + } + } } - for _, tsk := range tasks { - if tsk.ID != *tpl.LastTaskID { - continue - } - - err = tsk.Fill(d) - if err != nil { - return - } - template.LastTask = &tsk - break - } templates = append(templates, template) }