Create a Verification on manual check
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
oclib "cloud.o-forge.io/core/oc-lib"
|
||||
"cloud.o-forge.io/core/oc-lib/dbs"
|
||||
"cloud.o-forge.io/core/oc-lib/models/common/enum"
|
||||
"cloud.o-forge.io/core/oc-lib/models/execution_verification"
|
||||
"cloud.o-forge.io/core/oc-lib/models/resources/native_tools"
|
||||
"cloud.o-forge.io/core/oc-lib/models/workflow_execution"
|
||||
"cloud.o-forge.io/core/oc-lib/tools"
|
||||
@@ -94,19 +95,29 @@ func (s *ScheduleManager) getExecution(from time.Time, to time.Time) (exec_list
|
||||
func (s *ScheduleManager) ExecuteWorkflow(resp tools.NATSResponse) {
|
||||
var event native_tools.WorkflowEventParams
|
||||
json.Unmarshal(resp.Payload, &event)
|
||||
access := oclib.NewRequestAdmin(oclib.LibDataEnum(oclib.WORKFLOW), nil)
|
||||
if d := access.LoadOne(fmt.Sprintf("%v", event.WorkflowResourceID)); d.Err == "" {
|
||||
eventExec := &workflow_execution.WorkflowExecution{
|
||||
WorkflowID: d.Data.GetID(),
|
||||
ExecDate: time.Now(),
|
||||
ExecutionsID: uuid.New().String(),
|
||||
State: enum.SCHEDULED,
|
||||
if event.ManualCheck {
|
||||
access := oclib.NewRequestAdmin(oclib.LibDataEnum(oclib.EXECUTION_VERIFICATION), nil)
|
||||
exec := &execution_verification.ExecutionVerification{
|
||||
WorkflowID: event.WorkflowResourceID,
|
||||
Payload: event.Payload,
|
||||
}
|
||||
exec := oclib.NewRequestAdmin(oclib.LibDataEnum(oclib.WORKFLOW_EXECUTION), nil).StoreOne(eventExec.Serialize(eventExec))
|
||||
if execc := exec.ToWorkflowExecution(); execc != nil {
|
||||
Executions.AddSchedules([]*workflow_execution.WorkflowExecution{execc}, s.Logger)
|
||||
access.StoreOne(exec.Serialize(exec))
|
||||
} else {
|
||||
access := oclib.NewRequestAdmin(oclib.LibDataEnum(oclib.WORKFLOW), nil)
|
||||
if d := access.LoadOne(fmt.Sprintf("%v", event.WorkflowResourceID)); d.Err == "" {
|
||||
eventExec := &workflow_execution.WorkflowExecution{
|
||||
WorkflowID: d.Data.GetID(),
|
||||
ExecDate: time.Now(),
|
||||
ExecutionsID: uuid.New().String(),
|
||||
State: enum.SCHEDULED,
|
||||
}
|
||||
exec := oclib.NewRequestAdmin(oclib.LibDataEnum(oclib.WORKFLOW_EXECUTION), nil).StoreOne(eventExec.Serialize(eventExec))
|
||||
if execc := exec.ToWorkflowExecution(); execc != nil {
|
||||
Executions.AddSchedules([]*workflow_execution.WorkflowExecution{execc}, s.Logger)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *ScheduleManager) GetNextScheduledWorkflows(_ tools.NATSResponse) {
|
||||
|
||||
Reference in New Issue
Block a user