diff --git a/models/workflow_execution/workflow_execution_mongo_accessor.go b/models/workflow_execution/workflow_execution_mongo_accessor.go index b14ec51..c08137c 100644 --- a/models/workflow_execution/workflow_execution_mongo_accessor.go +++ b/models/workflow_execution/workflow_execution_mongo_accessor.go @@ -45,7 +45,7 @@ func (a *workflowExecutionMongoAccessor) LoadOne(id string) (utils.DBObject, int return utils.GenericLoadOne[*WorkflowExecutions](id, func(d utils.DBObject) (utils.DBObject, int, error) { if d.(*WorkflowExecutions).State == enum.DRAFT && time.Now().UTC().After(d.(*WorkflowExecutions).ExecDate) { utils.GenericDeleteOne(d.GetID(), a) - return nil, 404, errors.New("Not found") + return nil, 404, errors.New("not found") } if d.(*WorkflowExecutions).State == enum.SCHEDULED && time.Now().UTC().After(d.(*WorkflowExecutions).ExecDate) { d.(*WorkflowExecutions).State = enum.FORGOTTEN diff --git a/models/workflow_execution/workflow_scheduler.go b/models/workflow_execution/workflow_scheduler.go index 0e9fabd..48633dc 100644 --- a/models/workflow_execution/workflow_scheduler.go +++ b/models/workflow_execution/workflow_scheduler.go @@ -48,7 +48,7 @@ func NewScheduler(start string, end string, durationInS float64, cron string) *W } func (ws *WorkflowSchedule) CheckBooking(wfID string, request *tools.APIRequest) (bool, *workflow.Workflow, []*WorkflowExecutions, error) { - if request.Caller == nil && request.Caller.URLS == nil && request.Caller.URLS[tools.BOOKING] == nil || request.Caller.URLS[tools.BOOKING][tools.POSTCHECK] == "" { + if request.Caller == nil && request.Caller.URLS == nil && request.Caller.URLS[tools.BOOKING] == nil || request.Caller.URLS[tools.BOOKING][tools.GET] == "" { return false, nil, []*WorkflowExecutions{}, errors.New("no caller defined") } access := workflow.NewAccessor(request) @@ -74,10 +74,13 @@ func (ws *WorkflowSchedule) CheckBooking(wfID string, request *tools.APIRequest) } for _, exec := range execs { bookings := exec.Book(wfID, priceds) - for _, booking := range bookings { - _, err := (&peer.Peer{}).LaunchPeerExecution(booking.DestPeerID, "", - tools.BOOKING, tools.POSTCHECK, booking.Serialize(booking), request.Caller) - fmt.Println("booking", booking, err) + for _, b := range bookings { + meth := request.Caller.URLS[tools.BOOKING][tools.GET] + meth = strings.ReplaceAll(meth, ":id", b.ResourceID) + meth = strings.ReplaceAll(meth, ":start_date", b.ExpectedStartDate.Format("2006-01-02T15:04:05")) + meth = strings.ReplaceAll(meth, ":end_date", b.ExpectedEndDate.Format("2006-01-02T15:04:05")) + request.Caller.URLS[tools.BOOKING][tools.GET] = meth + _, err := (&peer.Peer{}).LaunchPeerExecution(b.DestPeerID, b.ResourceID, tools.BOOKING, tools.GET, nil, request.Caller) if err != nil { return false, wf, execs, err }