@@ -36,14 +36,7 @@ type WorkflowConfigSnapshot struct {
36
36
37
37
type WorkflowConfigSnapshotRepository interface {
38
38
SaveWithTx (tx * pg.Tx , snapshot * WorkflowConfigSnapshot ) (* WorkflowConfigSnapshot , error )
39
- UpdateWithTx (tx * pg.Tx , snapshot * WorkflowConfigSnapshot ) error
40
- FindById (id int ) (* WorkflowConfigSnapshot , error )
41
- FindByWorkflowIdAndType (workflowId int , workflowType types.WorkflowType ) (* WorkflowConfigSnapshot , error )
42
- FindByPipelineId (pipelineId int , limit int , offset int ) ([]* WorkflowConfigSnapshot , error )
43
- FindByAppId (appId int , limit int , offset int ) ([]* WorkflowConfigSnapshot , error )
44
- FindLatestByPipelineIdAndType (pipelineId int , workflowType types.WorkflowType ) (* WorkflowConfigSnapshot , error )
45
39
// New methods for retrigger functionality
46
- FindLatestByWorkflowIdAndType (workflowId int , workflowType types.WorkflowType ) (* WorkflowConfigSnapshot , error )
47
40
FindLatestFailedWorkflowSnapshot (workflowId int , workflowType types.WorkflowType ) (* WorkflowConfigSnapshot , error )
48
41
sql.TransactionWrapper
49
42
}
@@ -71,110 +64,13 @@ func (impl *WorkflowConfigSnapshotRepositoryImpl) SaveWithTx(tx *pg.Tx, snapshot
71
64
return snapshot , nil
72
65
}
73
66
74
- func (impl * WorkflowConfigSnapshotRepositoryImpl ) UpdateWithTx (tx * pg.Tx , snapshot * WorkflowConfigSnapshot ) error {
75
- err := tx .Update (snapshot )
76
- if err != nil {
77
- impl .logger .Errorw ("error in updating workflow config snapshot with tx" , "err" , err , "snapshot" , snapshot )
78
- return err
79
- }
80
- return nil
81
- }
82
-
83
- func (impl * WorkflowConfigSnapshotRepositoryImpl ) FindById (id int ) (* WorkflowConfigSnapshot , error ) {
84
- snapshot := & WorkflowConfigSnapshot {}
85
- err := impl .dbConnection .Model (snapshot ).
86
- Where ("id = ?" , id ).
87
- Select ()
88
- if err != nil {
89
- impl .logger .Errorw ("error in finding workflow config snapshot by id" , "err" , err , "id" , id )
90
- return snapshot , err
91
- }
92
- return snapshot , nil
93
- }
94
-
95
- func (impl * WorkflowConfigSnapshotRepositoryImpl ) FindByWorkflowIdAndType (workflowId int , workflowType types.WorkflowType ) (* WorkflowConfigSnapshot , error ) {
96
- snapshot := & WorkflowConfigSnapshot {}
97
- err := impl .dbConnection .Model (snapshot ).
98
- Where ("workflow_id = ?" , workflowId ).
99
- Where ("workflow_type = ?" , workflowType ).
100
- Select ()
101
- if err != nil {
102
- impl .logger .Errorw ("error in finding workflow config snapshot by workflow id and type" , "err" , err , "workflowId" , workflowId , "workflowType" , workflowType )
103
- return snapshot , err
104
- }
105
- return snapshot , nil
106
- }
107
-
108
- func (impl * WorkflowConfigSnapshotRepositoryImpl ) FindByPipelineId (pipelineId int , limit int , offset int ) ([]* WorkflowConfigSnapshot , error ) {
109
- var snapshots []* WorkflowConfigSnapshot
110
- err := impl .dbConnection .Model (& snapshots ).
111
- Where ("pipeline_id = ?" , pipelineId ).
112
- Order ("created_on DESC" ).
113
- Limit (limit ).
114
- Offset (offset ).
115
- Select ()
116
- if err != nil {
117
- impl .logger .Errorw ("error in finding workflow config snapshots by pipeline id" , "err" , err , "pipelineId" , pipelineId )
118
- return snapshots , err
119
- }
120
- return snapshots , nil
121
- }
122
-
123
- func (impl * WorkflowConfigSnapshotRepositoryImpl ) FindByAppId (appId int , limit int , offset int ) ([]* WorkflowConfigSnapshot , error ) {
124
- var snapshots []* WorkflowConfigSnapshot
125
- err := impl .dbConnection .Model (& snapshots ).
126
- Where ("app_id = ?" , appId ).
127
- Order ("created_on DESC" ).
128
- Limit (limit ).
129
- Offset (offset ).
130
- Select ()
131
- if err != nil {
132
- impl .logger .Errorw ("error in finding workflow config snapshots by app id" , "err" , err , "appId" , appId )
133
- return snapshots , err
134
- }
135
- return snapshots , nil
136
- }
137
-
138
- func (impl * WorkflowConfigSnapshotRepositoryImpl ) FindLatestByPipelineIdAndType (pipelineId int , workflowType types.WorkflowType ) (* WorkflowConfigSnapshot , error ) {
139
- snapshot := & WorkflowConfigSnapshot {}
140
- err := impl .dbConnection .Model (snapshot ).
141
- Where ("pipeline_id = ?" , pipelineId ).
142
- Where ("workflow_type = ?" , workflowType ).
143
- Order ("created_on DESC" ).
144
- Limit (1 ).
145
- Select ()
146
- if err != nil {
147
- impl .logger .Errorw ("error in finding latest workflow config snapshot by pipeline id and type" , "err" , err , "pipelineId" , pipelineId , "workflowType" , workflowType )
148
- return snapshot , err
149
- }
150
- return snapshot , nil
151
- }
152
-
153
- // FindLatestByWorkflowIdAndType finds the latest workflow config snapshot by workflow ID and type
154
- func (impl * WorkflowConfigSnapshotRepositoryImpl ) FindLatestByWorkflowIdAndType (workflowId int , workflowType types.WorkflowType ) (* WorkflowConfigSnapshot , error ) {
155
- snapshot := & WorkflowConfigSnapshot {}
156
- err := impl .dbConnection .Model (snapshot ).
157
- Where ("workflow_id = ?" , workflowId ).
158
- Where ("workflow_type = ?" , workflowType ).
159
- Order ("created_on DESC" ).
160
- Limit (1 ).
161
- Select ()
162
- if err != nil {
163
- impl .logger .Errorw ("error in finding latest workflow config snapshot by workflow id and type" , "err" , err , "workflowId" , workflowId , "workflowType" , workflowType )
164
- return snapshot , err
165
- }
166
- return snapshot , nil
167
- }
168
-
169
67
// FindLatestFailedWorkflowSnapshot finds the latest failed workflow snapshot for retrigger
170
68
// This method looks for the original workflow that failed, not the retrigger attempts
171
69
func (impl * WorkflowConfigSnapshotRepositoryImpl ) FindLatestFailedWorkflowSnapshot (workflowId int , workflowType types.WorkflowType ) (* WorkflowConfigSnapshot , error ) {
172
70
snapshot := & WorkflowConfigSnapshot {}
173
71
err := impl .dbConnection .Model (snapshot ).
174
72
Where ("workflow_id = ?" , workflowId ).
175
73
Where ("workflow_type = ?" , workflowType ).
176
- //Order("created_on DESC").
177
- //Limit(1).
178
74
Select ()
179
75
if err != nil {
180
76
impl .logger .Errorw ("error in finding latest failed workflow config snapshot" , "err" , err , "workflowId" , workflowId , "workflowType" , workflowType )
0 commit comments