Booking trace API

This commit is contained in:
mr 2024-08-21 14:12:28 +02:00
parent ddb4f76af7
commit c14e067449

View File

@ -80,7 +80,7 @@ func (wfa *workflowMongoAccessor) getExecutions(id string, data *Workflow) ([]*w
func (wfa *workflowMongoAccessor) DeleteOne(id string) (utils.DBObject, int, error) {
wfa.execution(id, &Workflow{
AbstractWorkflow: AbstractWorkflow{ScheduleActive: true},
AbstractWorkflow: AbstractWorkflow{ScheduleActive: false},
}, true)
return wfa.GenericDeleteOne(id, wfa)
}
@ -138,16 +138,14 @@ func (wfa *workflowMongoAccessor) book(id string, realData *Workflow, execs []*w
}
func (wfa *workflowMongoAccessor) execution(id string, realData *Workflow, delete bool) (int, error) {
if !realData.ScheduleActive {
return 200, nil
}
var err error
nats := tools.NewNATSCaller()
res, code, _ := wfa.LoadOne(id)
if code != 200 {
return 404, errors.New("could not load workflow")
}
if realData.Schedule == nil && realData.ScheduleActive {
r := res.(*Workflow)
if r.Schedule != nil && !realData.ScheduleActive {
mongo.MONGOService.DeleteMultiple(map[string]interface{}{
"state": 1,
"workflow_id": id,
@ -157,7 +155,6 @@ func (wfa *workflowMongoAccessor) execution(id string, realData *Workflow, delet
return 200, err
}
r := res.(*Workflow)
if r.Schedule != nil && r.Schedule.Start == realData.Schedule.Start && r.Schedule.End == realData.Schedule.End && r.Schedule.Cron == realData.Schedule.Cron {
return 200, nil
}