@@ -28,12 +28,12 @@ import (
28
28
29
29
type WorkflowStatusLatestService interface {
30
30
// CI Workflow Status Latest methods
31
- SaveOrUpdateCiWorkflowStatusLatest (pipelineId , appId , ciWorkflowId int , status string , userId int32 ) error
31
+ SaveOrUpdateCiWorkflowStatusLatest (pipelineId , appId , ciWorkflowId int , userId int32 ) error
32
32
GetCiWorkflowStatusLatestByPipelineId (pipelineId int ) (* CiWorkflowStatusLatest , error )
33
33
GetCiWorkflowStatusLatestByAppId (appId int ) ([]* CiWorkflowStatusLatest , error )
34
34
35
35
// CD Workflow Status Latest methods
36
- SaveOrUpdateCdWorkflowStatusLatest (pipelineId , appId , environmentId , workflowRunnerId int , workflowType , status string , userId int32 ) error
36
+ SaveOrUpdateCdWorkflowStatusLatest (pipelineId , appId , environmentId , workflowRunnerId int , workflowType string , userId int32 ) error
37
37
GetCdWorkflowStatusLatestByPipelineIdAndWorkflowType (pipelineId int , workflowType string ) (* CdWorkflowStatusLatest , error )
38
38
GetCdWorkflowStatusLatestByAppId (appId int ) ([]* CdWorkflowStatusLatest , error )
39
39
GetCdWorkflowStatusLatestByPipelineId (pipelineId int ) ([]* CdWorkflowStatusLatest , error )
@@ -65,7 +65,7 @@ type CiWorkflowStatusLatest struct {
65
65
PipelineId int `json:"pipelineId"`
66
66
AppId int `json:"appId"`
67
67
CiWorkflowId int `json:"ciWorkflowId"`
68
- Status string `json:"status"`
68
+ Status string `json:"status"` // Derived from ci_workflow table
69
69
}
70
70
71
71
type CdWorkflowStatusLatest struct {
@@ -74,11 +74,11 @@ type CdWorkflowStatusLatest struct {
74
74
EnvironmentId int `json:"environmentId"`
75
75
WorkflowType string `json:"workflowType"`
76
76
WorkflowRunnerId int `json:"workflowRunnerId"`
77
- Status string `json:"status"`
77
+ Status string `json:"status"` // Derived from cd_workflow_runner table
78
78
}
79
79
80
80
// CI Workflow Status Latest methods implementation
81
- func (impl * WorkflowStatusLatestServiceImpl ) SaveOrUpdateCiWorkflowStatusLatest (pipelineId , appId , ciWorkflowId int , status string , userId int32 ) error {
81
+ func (impl * WorkflowStatusLatestServiceImpl ) SaveOrUpdateCiWorkflowStatusLatest (pipelineId , appId , ciWorkflowId int , userId int32 ) error {
82
82
// Check if entry exists
83
83
existingEntry , err := impl .workflowStatusLatestRepository .GetCiWorkflowStatusLatestByPipelineId (pipelineId )
84
84
if err != nil && err != pg .ErrNoRows {
@@ -93,7 +93,6 @@ func (impl *WorkflowStatusLatestServiceImpl) SaveOrUpdateCiWorkflowStatusLatest(
93
93
PipelineId : pipelineId ,
94
94
AppId : appId ,
95
95
CiWorkflowId : ciWorkflowId ,
96
- Status : status ,
97
96
}
98
97
model .CreatedBy = userId
99
98
model .CreatedOn = now
@@ -104,7 +103,6 @@ func (impl *WorkflowStatusLatestServiceImpl) SaveOrUpdateCiWorkflowStatusLatest(
104
103
} else {
105
104
// Update existing entry
106
105
existingEntry .CiWorkflowId = ciWorkflowId
107
- existingEntry .Status = status
108
106
existingEntry .UpdatedBy = userId
109
107
existingEntry .UpdatedOn = now
110
108
@@ -123,11 +121,18 @@ func (impl *WorkflowStatusLatestServiceImpl) GetCiWorkflowStatusLatestByPipeline
123
121
return nil , err
124
122
}
125
123
124
+ // Get status from ci_workflow table
125
+ ciWorkflow , err := impl .ciWorkflowRepository .FindById (model .CiWorkflowId )
126
+ if err != nil {
127
+ impl .logger .Errorw ("error in getting ci workflow" , "err" , err , "ciWorkflowId" , model .CiWorkflowId )
128
+ return nil , err
129
+ }
130
+
126
131
return & CiWorkflowStatusLatest {
127
132
PipelineId : model .PipelineId ,
128
133
AppId : model .AppId ,
129
134
CiWorkflowId : model .CiWorkflowId ,
130
- Status : model .Status ,
135
+ Status : ciWorkflow .Status ,
131
136
}, nil
132
137
}
133
138
@@ -140,11 +145,18 @@ func (impl *WorkflowStatusLatestServiceImpl) GetCiWorkflowStatusLatestByAppId(ap
140
145
141
146
var result []* CiWorkflowStatusLatest
142
147
for _ , model := range models {
148
+ // Get status from ci_workflow table
149
+ ciWorkflow , err := impl .ciWorkflowRepository .FindById (model .CiWorkflowId )
150
+ if err != nil {
151
+ impl .logger .Errorw ("error in getting ci workflow" , "err" , err , "ciWorkflowId" , model .CiWorkflowId )
152
+ continue // Skip this entry if we can't get the workflow
153
+ }
154
+
143
155
result = append (result , & CiWorkflowStatusLatest {
144
156
PipelineId : model .PipelineId ,
145
157
AppId : model .AppId ,
146
158
CiWorkflowId : model .CiWorkflowId ,
147
- Status : model .Status ,
159
+ Status : ciWorkflow .Status ,
148
160
})
149
161
}
150
162
0 commit comments