Skip to content

Commit 137e27f

Browse files
committed
fix(tasks): fix loading data from boltdb
1 parent c47e9d1 commit 137e27f

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

api/projects/tasks.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ func GetTaskStages(w http.ResponseWriter, r *http.Request) {
186186
}
187187

188188
for i := range stages {
189+
if stages[i].JSON == "" {
190+
continue
191+
}
189192
var res any
190193
err = json.Unmarshal([]byte(stages[i].JSON), &res)
191194
if err != nil {

db/bolt/task.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,25 @@ func (d *BoltDb) GetTaskStages(projectID int, taskID int) (res []db.TaskStageWit
2222
return
2323
}
2424

25-
err = d.getObjects(taskID, db.TaskStageProps, db.RetrieveQueryParams{}, nil, &res)
25+
var stages []db.TaskStage
26+
err = d.getObjects(taskID, db.TaskStageProps, db.RetrieveQueryParams{}, nil, &stages)
27+
if err != nil {
28+
return
29+
}
30+
31+
// Convert TaskStage to TaskStageWithResult
32+
res = make([]db.TaskStageWithResult, len(stages))
33+
for i, stage := range stages {
34+
res[i] = db.TaskStageWithResult{
35+
ID: stage.ID,
36+
TaskID: stage.TaskID,
37+
Start: stage.Start,
38+
End: stage.End,
39+
StartOutputID: stage.StartOutputID,
40+
EndOutputID: stage.EndOutputID,
41+
Type: stage.Type,
42+
}
43+
}
2644

2745
return
2846
}

0 commit comments

Comments
 (0)