light modification
This commit is contained in:
parent
9c71730d9c
commit
e6ac7d0da6
@ -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) {
|
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) {
|
if d.(*WorkflowExecutions).State == enum.DRAFT && time.Now().UTC().After(d.(*WorkflowExecutions).ExecDate) {
|
||||||
utils.GenericDeleteOne(d.GetID(), a)
|
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) {
|
if d.(*WorkflowExecutions).State == enum.SCHEDULED && time.Now().UTC().After(d.(*WorkflowExecutions).ExecDate) {
|
||||||
d.(*WorkflowExecutions).State = enum.FORGOTTEN
|
d.(*WorkflowExecutions).State = enum.FORGOTTEN
|
||||||
|
@ -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) {
|
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")
|
return false, nil, []*WorkflowExecutions{}, errors.New("no caller defined")
|
||||||
}
|
}
|
||||||
access := workflow.NewAccessor(request)
|
access := workflow.NewAccessor(request)
|
||||||
@ -74,10 +74,13 @@ func (ws *WorkflowSchedule) CheckBooking(wfID string, request *tools.APIRequest)
|
|||||||
}
|
}
|
||||||
for _, exec := range execs {
|
for _, exec := range execs {
|
||||||
bookings := exec.Book(wfID, priceds)
|
bookings := exec.Book(wfID, priceds)
|
||||||
for _, booking := range bookings {
|
for _, b := range bookings {
|
||||||
_, err := (&peer.Peer{}).LaunchPeerExecution(booking.DestPeerID, "",
|
meth := request.Caller.URLS[tools.BOOKING][tools.GET]
|
||||||
tools.BOOKING, tools.POSTCHECK, booking.Serialize(booking), request.Caller)
|
meth = strings.ReplaceAll(meth, ":id", b.ResourceID)
|
||||||
fmt.Println("booking", booking, err)
|
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 {
|
if err != nil {
|
||||||
return false, wf, execs, err
|
return false, wf, execs, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user